Hello Everyone, I am trying to update price-level ...
# suitescript
a
Hello Everyone, I am trying to update price-level on the Matrix Parent Item using a User Event Script (beforeSubmit / afterSubmit) based on changes to another custom field. Challenge: Whenever the custom field is updated on the Matrix Parent Item, the UI have only update matrix to save the parent record. Goal: I want to ensure that the Mass Update ignores only this price-level, so the change does not propagate to Matrix Child Items. 🔹 Any suggestions on how to achieve this? Would appreciate any insights! Thanks.
a
you can just exclude all the subitems before hitting update Matrix
a
Hey @Anthony OConnor, I need the matrix sub-items to ignore only few custom fields, rest other information that has been changed should be updated.
a
you have a custitem field that when set you want to trigger an update to the price level? but you don't want that pricelevel update to copy down to the subitems?
a
Yes, but the custitem field should update to the sub-items.
a
not sure if I have enough of the details to be sure, but something like this could work, it really depends on what your trigger conditions are, and if you'd want subsequent updates to take effect, or not unless that cust field value changes again... but I'm thinking something like this.
Copy code
beforeSubmit(context){
    var or = context.oldRecord;
    var nr = context.newRecord;
    
    var oldPrice = or.getValue({fieldId: 'price});
    
    var hasParent = nr.getValue({fieldId: 'parent'});

    if(hasParent){
        var testVal = nr.getValue({ fieldId: 'custitem_mycustfield'});
        if (testVal === %value you care about&){
            nr.setValue({ fieldId: 'price', value: oldPrice });
        }
    }
}
i just typed this directly in slack, its not code I actually ran
for example, if your cust field is just a checkbox called "LOCK CHILD PRICES" then this should work if your cust field instead represents something else entirely and you're only using it to INFER a the child price lock for this ONE TIME of updates, then it gets a little trickier 😛