I am adding an item group via a scripted search. H...
# suitescript
p
I am adding an item group via a scripted search. How can I have the order the items are imported in match the order in the item group?
b
probably depends on what you are doing with the search
i think the obvious choice of a item search with a member item column automatically has the member items in the correct order in the default sort
though i personally wonder why not straight up use the item group in the first place
p
Reason is I need to do some additional scripting when the item list loads. The quantity field is populated from a main line field. If I add the item group from the UI the script does not trigger and per netsuite this is standard. I have no sort in my search and it appears to be adding the items by internal I'd
b
What are your filters and columns
p
Copy code
filters:
            [
               ["type","anyof","Group"], 
               "AND", 
               ["internalid","anyof","1157"]
            ],
            columns:
            [
               search.createColumn({
                  name: "itemid",
                  label: "Name"
               }),
               search.createColumn({
                  name: "internalid",
                  join: "memberItem",
                  label: "Name"
               }),
               search.createColumn({
                  name: "vendorpricecurrency",
                  join: "memberItem",
                  label: "Vendor Price Currency"
               }),
               search.createColumn({
                  name: "baseprice",
                  join: "memberItem",
                  label: "Base Price"
               }),
               search.createColumn({
                  name: "saleunit",
                  join: "memberItem",
                  label: "Primary Sale Unit"
               }),
               search.createColumn({
                  name: "minimumquantity",
                  join: "memberItem",
                  label: "Minimum Quantity"
               })
            ]
b
you can force the sort by adding the member line column
and sorting by it
p
got it! thanks!
hmmm...cant seem to find that column. I tried the following: var itemLine = result.getValue({                   name: "linenumber",                   join: "memberItem"});
and:
Copy code
var itemLine = result.getValue({
                  name: "linenumber"});
b
its not part of the memberitem join, look at the columns in the search for a column named member line
p
Not sure why but I do not have this column available. This is what I show:
per Netsuite customer support I need to have the Assembly Item Feature in order to be able to sort by Member Line.
I ended up creating a custom field in the item record and will sort via that.