This topic contains 5 replies, has 0 voices, and was last updated by sterlingr 8 years ago.

  • Author
    Posts
  • #5980

    sterlingr

    Hello,

    I’m trying to update a script and I want to find if an item is a matrix child item and run certain commands based on that. I’ve searched everywhere and I can’t find the correct method to find if an item is a matrix child. I see you can set search criteria to matrix child items=t. I could do something like adding a custom field and set that true or false with a mass update?

    Is there any direct approach to find if the item is a child item?

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

  • #5981

    david.smith

    Code:
    var itemSearchObj = search.create({
    type: “item”,
    filters: [
    [“matrix”,”is”,”T”]
    ],
    columns: [
    “itemid”,
    “displayname”,
    “salesdescription”,
    “type”,
    “baseprice”
    ]
    });
    itemSearchObj.run().each(function(result){
    return true;
    });

  • #5982

    robert.paulson

    Hi sterlingr,

    If you need use a scripted search to fetch specific matrix subitems, then you can use the following snippet:

    Code:
    var filters = [[‘matrixchild’,’is’,’T’]]; var columns = []; nlapiSearchRecord(“item”,null,filters,columns);
    If you’re on an item record and need to verify if it is a matrix subitem, then use the following:

    Code:
    nlapiGetFieldValue(‘hasparent’);
    It will also work if you load the record:

    Code:
    rec.getFieldValue(‘hasparent’);
    Hope that helps,

    – Robert

  • #5983

    sterlingr

    Thanks guys. I went ahead and setup a custom field for it because I want it available for multiple applications. I am going to work more with the search records though and see how that would apply. I’m still getting my feet wet here.

    Also, I did try ‘hasparent’ but that doesn’t work as expected — It shows true for any item that has a parent even non matrix items (which is pretty much all of our items). I simply need the nlapiGetFieldValue(‘matrixchild’) option but that doesn’t work.

  • #5984

    fourthwaveconsulting

    I highly recommend the ‘search export’ chrome extension – you can edit a saved search and click a button to see the scripted version of that search. super useful:

    https://chrome.google.com/webstore/d…er-info-dialog

    David Smith’s code should work for what you want.

  • #5985

    sterlingr

    That is brilliant. Added both of his extensions! Thanks!

You must be logged in to reply to this topic.