I have a script that adds an item group via a butt...
# suitescript
p
I have a script that adds an item group via a button press. Works great but I would also like to have the quantity field update based on the unit type for certain line items in the item group and the quantity would come from a field in the transaction. When i check the console log I see that the Original Unit is blank which leads me to believe it is because it is an item group and the items are already added. Is there a way to get the unit type from items in an item group?
Copy code
if (recordType == 'estimate') {
        rec.selectNewLine({ sublistId: 'item'})
        rec.setCurrentSublistValue({ 
          sublistId: 'item',
          fieldId: 'item',
          value: 1157, 
          forceSyncSourcing: true
        })
        var origUnit = rec.getCurrentSublistValue({
           sublistId: 'item',
           fieldId: 'units'
        });
        console.log("Original Unit = " + origUnit);
        if (origUnit == '2') { 
           rec.setCurrentSublistValue({ 
           sublistId: 'item',
           fieldId: 'quantity',
           value: myQuantity, 
           forceSyncSourcing: true
           })
        }
       } 
       rec.commitLine({"sublistId": "item"});
b
you probably want to explain this better
if you mean Item Groups, both your description and code make little sense
item groups dont have uom, and while the components might, thats not what your code does
p
Yes. Was referring to Item Groups. i do see what you mean about an item group not having uom.
b
how do you enter uom on an item group record
p
I don't. I was under the assumption that once the item members loaded I could get the uom from that.
b
thats what i was saying about your code
it doesnt try to get the units of the components
it tries to get it from the group item, which will fail
since it has none