Latheesan
Latheesan

Reputation: 24116

NetSuite UserEvents afterSubmit is not firing

I have a very simple User Event script, which looks like this:

define(["N/log"], function(log) {
    var exports = {};

    function beforeSubmit(scriptContext) {
        log.debug({
            title: "Before Submit",
            details: JSON.stringify(scriptContext)
        });
    }

    function afterSubmit(scriptContext) {
        log.debug({
            title: "After Submit",
            details: JSON.stringify(scriptContext)
        });
    }

    exports.beforeSubmit = beforeSubmit;
    exports.afterSubmit = afterSubmit;
    return exports;
});

I have created the Script record and then deployed it with the following settings:

Applies To: - All Records - Deployed: Ticked Status: Testing Event Type: not specified Log Level: Debug Execute as Role: Current Role

and we've configured all of the audience setting also.

After deploying the script, we tried to create a new Customer Deposit and expected to see a log entry in Execution Log for this script deployment - however it appears to be empty.

We did not get any unhandled exception error either.

Any idea what might be wrong here?

Upvotes: 1

Views: 1427

Answers (2)

xpeldev
xpeldev

Reputation: 2080

what @bknights said and try 'inlining' your returns:

return { beforeSubmit: beforeSubmitFuncName, ... };

Upvotes: 0

bknights
bknights

Reputation: 15367

If that's your whole script then Netsuite is interpreting it as an SS1.0 script and is giving it a different script engine.

Your script needs to start with the JSDoc comments that SS2.0 expects:

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(...

Note you'll probably need to delete the existing script and script file before importing the fixed script file and defining a new User Event script.

Upvotes: 3

Related Questions