will a workflow trigger on sublist edit?
# suitescript
l
will a workflow trigger on sublist edit?
m
A workflow can only interact with the items Sublist on transactions and the expenses Sublist on expense reports
Is that what you mean?
l
i see well im trying to trigger a workflow through a UE script that triggers in xEDIT on a custom record? would that work
e
User Events (whether Workflows or Scripts) do not trigger each other.
l
well i specifically wrote a UE script to trigger a workflow. this is not a random UE script
its working, its not working on inline edit tho
e
Does your Workflow have the "Direct List Edit" Event Type?
l
yes its running in all contexts, no restrictions
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(['N/record', 'N/log', 'N/workflow'], function(record, log, workflow) {

    function beforeSubmit(context) {
        try {
            if (context.type === context.UserEventType.XEDIT) {
          // Get the record ID
                var recordId = context.newRecord.id;
                // Trigger the workflow
                var workflowId = 'customworkflow_send_email_on_backordered'; // Replace with your actual workflow ID
                var workflowTrigger = workflow.trigger({
                    recordType: context.newRecord.type,
                    recordId: recordId,
                    workflowId: workflowId
                });

                log.debug('Workflow Triggered', 'Workflow ID: ' + workflowTrigger);
        }
        } catch (e) {
            log.error('Error Triggering Workflow', e.message);
        }
    }

    return {
        beforeSubmit: beforeSubmit
    };

});
e
I don't know how the workflow module and the context events interact, but my guess would be that your workflow must have the "User Event" context, the "Betore Submit" trigger type, and the "Direct List Edit" event type.
l
maybe i didnt explain myself correctly, but the script is not triggering on xedit at all. it doesnt even get to the workflow.