is there a way to trigger UE scripts with records ...
# suitescript
i
is there a way to trigger UE scripts with records updated via bulk processing?
t
Yes, UE's trigger on mass updates, csv and scheduled trigger types provided the UE hasn't excluded them
j
Note that if you create a Saved Mass Update (not a scripted one) it WILL run UE scripts even if they have “Custom Mass Update” unselected under context.
b
depends on the bulk processing, some trigger, some dont
on the ones that do, their execution context is user event script, which is extra weird
wow 1
i
Saw the issue, but now have another one. So the cash sale is created trough the bulk processing Sales Order -> Invoice sales orders, now this one triggers the Cash Sale UE, on this script had a condition
Copy code
// redirect.toSuitelet only works on UI, not when doing bulk transactions
if (runtime.executionContext === 'USERINTERFACE') {
  callSuitelet({ id, type, dataToSend });
}
if (runtime.executionContext === 'USEREVENT') {
   editOrderStatus({ id, type, dataToSend });
}
Apparently when i did my tests, when bulk processing the context was USERINTERFACE but now the context is USEREVENT. Now i just commented that out and let the callSuitelet function but on my tests for some reason the callSuitelet is not triggering the suitelet, on the logs of the suitelet I have a function right at the beginning and this is not being printed
Copy code
const callSuitelet = ({ id, type, dataToSend }) => {
        const fn = 'callSuitelet';
      log.debug({ title: `${fn}`, details: 'start...' });
        try {
            // call to suitelet to trigger UE transaction trigger, UE cant chain other UEs
            const params = {
                id,
                type,
                externalid: dataToSend.externalId,
            };
          log.debug({ title: params, details: params });
            redirect.toSuitelet({
                scriptId: 'customscript_bit_su_he',
                deploymentId: 'customdeploy_bit_su_he',
                parameters: params,
            });
        } catch (error) {
            log.error({ title: `Error: ${fn}`, details: error });
        }
    };
b
whoever wrote the code originally left the helpful explanation
i
I mean I wrote the code hahaha, thats why is weird that before, the context was another one that the one that im getting today, thats the reason I put that comment, I knew this was gonna be helpful for my future self 😅
but yeah, netsuite is weird sometimes u.u
b
you shouldnt be getting the user event context type unless you are using the invoice sales order page