Hi!, I'm trying to add a user event aftersubmit on...
# suitescript
p
Hi!, I'm trying to add a user event aftersubmit on the vendorsubsidiary-relationship but it does not seem to trigger when editing a vendor and changing or adding the subsidiary level record. Any ideas?
🙌 1
w
I don't think UE-scripts on child records will trigger when they are edited through the parent record sublist. Only when you CSV-import or edit the record directly. Could you create a UE-script on the vendor instead? (or client)
p
Tack Tomas 🙂 I tried also with an aftersubmit UE-script on the vendor and update the vendor-subsidiary relationship records (with a search and record.submitfields but I get unexpected/undesired results (some fields are not updated etc)
w
What are you trying to do? Have you tried updating the sublist on the vendor in BeforeSubmit?
(The sublist is called "submachine")
p
I'm trying to replicate the field "taxitem" in a custom field on the vendor-subsidiary record (to be able to access the tax code from sql, taxitem is not exposed in suite analytics).
Thanks for the tip, I'll check if I can do it in a beforesubmit
w
Works pretty well:
Copy code
const newRec = context.newRecord
  const lineCount = newRec.getLineCount({sublistId: 'submachine'})
  for(let line=0;line<lineCount;line++){
    newRec.setSublistValue({
      fieldId: 'custrecord_tax_item_copy',
      line,
      sublistId:'submachine',
      value: newRec.getSublistValue({sublistId:'submachine', line, fieldId:'taxitem'})
    })
  }
p
great! thanks!