This topic contains 5 replies, has 0 voices, and was last updated by sterlingr 8 years ago.
-
AuthorPosts
-
November 8, 2016 at 12:53 pm #5980
sterlingrHello,
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. -
November 8, 2016 at 1:09 pm #5981
david.smithCode:
var itemSearchObj = search.create({
type: “item”,
filters: [
[“matrix”,”is”,”T”]
],
columns: [
“itemid”,
“displayname”,
“salesdescription”,
“type”,
“baseprice”
]
});
itemSearchObj.run().each(function(result){
return true;
}); -
November 11, 2016 at 8:23 am #5982
robert.paulsonHi 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
-
November 11, 2016 at 9:52 am #5983
sterlingrThanks 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.
-
November 11, 2016 at 10:13 am #5984
fourthwaveconsultingI 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.
-
November 11, 2016 at 10:20 am #5985
sterlingrThat is brilliant. Added both of his extensions! Thanks!
-
AuthorPosts
You must be logged in to reply to this topic.