Trying to create my first one... is there a way to...
# suitescript
m
Trying to create my first one... is there a way to trigger a script so that if a line field on the item receipt has been updated to then go to the created from record (in this case PO) and update a body level field? Trying to find in the doc created from however unable to...
e
Definitely possible, but not a simple first script so might take a little trial & error. You’ll want to create a UserEvent script using the AfterSubmit method, meaning that it will fire after the Item Receipt has been saved to the database. It will need to compare the old and new values on the Item Receipt record using the scriptContext.newRecord and scriptContext.oldRecord passed into the afterSubmit method. If you detect a change, you can then do a simple record.update on the PO.
m
thanks @eblackey, so I realised it will be an AfterSubmit, what would need to be passed on for the oldRecord and newRecord comparison and how do I go from the current record of item receipt to the created from record? Basically trying to set the parameters and variables and wanting to add if createdfrom record type is PO then go to record and update value...
e
You’ll need to look at the ‘item’ sublist of each record - old and new and compare. You’ll need to use functions like getLineCount() to loop through each line and then getSublistValue() to get values.