This topic contains 2 replies, has 0 voices, and was last updated by Xiaoxin Lee 6 years, 9 months ago.

  • Author
    Posts
  • #21348

    Xiaoxin Lee

    Does anyone have succeeded to create Matrix Parent and Child Item by script?

    Recently, I have tried to create Matrix Parent Item.

    First of all, set values on 'itemid', 'displayname' fields and set 'matrixtype' field as 'PARENT'.

    For mandatory fields, set 'cogsaccount', 'assetaccount', 'taxschedule' fields with suitable values.

    After defining the Item's options part, tried to submit parent record using nlapiSubmitRecord function.

    But the Execution Log shows such result.

    UNEXPECTED_ERROR: null

    Is there a way around this?

    Thanks,

    Xiaoxin

    Here is the code snippet.

    ===============================================

    function suitelet(request, response){

    var recMatrixParent = nlapiCreateRecord('inventoryitem');

    recMatrixParent.setFieldValue('itemid', 'Matrix Parent');

    recMatrixParent.setFieldValue('displayname', 'Matrix Parent');

    recMatrixParent.setFieldValue('matrixtype', 'PARENT');

    recMatrixParent.setFieldValue('cogsaccount', 794);

    recMatrixParent.setFieldValue('assetaccount', 738);

    recMatrixParent.setFieldValue('taxschedule', 2);

    var arrColor = [1,2];

    // define the Item's options

    recMatrixParent.setFieldValue('custitem33', arrColor);

    var idMatrixParent = nlapiSubmitRecord(recMatrixParent);

    }

    ================================================
    This is a cached copy. Click here to see the original post.

  • #21349

    pcutler

    For a multi-select, you want setFieldValues (plural):

    // define the Item's options

    recMatrixParent.setFieldValues('custitem33', arrColor);

  • #21350

    Xiaoxin Lee

    Good point.

    But it produces same error results again.


    lisa.reed replied on 02/27/2018, 11:10 AM: Did you solve this? I am looking for ways to convert existing items to become child items and to upload the parent item to link it to. Client went live without implementing matrix items and now wants this feature! Any ideas!

You must be logged in to reply to this topic.