Hello, I did create a UE script on Estimate that ...
# suitescript
t
Hello, I did create a UE script on Estimate that triggers a SuiteLet to XEDIT the related Opportunity to triggers some other UE scripts that are on that opportunity. It's working fine, but when I check the APM Performance tool, i see it's running in 2.5 seconds on the Save action (in sandbox) . I know afterSubmit is Synchronous, but do you know if all the 2.5 seconds are impacting UI ? Do you recommmend a better option ?
Copy code
const afterSubmit = (scriptContext) => {
    try {
        if (scriptContext.type === scriptContext.UserEventType.CREATE || scriptContext.type === scriptContext.UserEventType.EDIT) {

            var opportunityId = scriptContext.newRecord.getValue({fieldId: 'opportunity'});
            if (!opportunityId) {return}
            log.debug('This Opportunity will be updated. ID:', opportunityId);

            var requestOptions = {
                scriptId: 'customscript_tg_sl_load_opp_from_quo', // Replace with your Suitelet script ID
                deploymentId: 'customdeploy1', // Replace with your Suitelet deployment ID
                urlParams: {
                    opportunityId: opportunityId // Passing the Opportunity ID as a parameter
                }
            };
            // Use the promise-based method to call the Suitelet
            https.requestSuitelet.promise(requestOptions)
            //https.requestSuitelet(requestOptions)

        }
    } catch (e) {
        log.error('Error in afterSubmit', e + e.stack);
    }
}
b
if you cared about performance, you wouldnt be trying to perform the work in a user event
they are synchronous, the user is waiting the entire time for the work to be done
ideally you would do the work in a scheduled script (or map/reduce) instead
less ideally, you would abstract out the logic performed by the other user event scripts into their own modules that you can call in this user event
t
ok thanks a lot. 🙂 They are using CPQ to create and update Quote. So i'm not sure if they do care a lot about perf in the UI for quote.