The quick answer
Return a value from the script's onAction entry point. Set the script's Return Type and the destination state-field type to Free-Form Text, then select that field in the custom action's Store Result In setting. After the workflow runs, inspect the stored state value separately from the script's execution logs.
This example returns READY, stores it in Action Result, and checks the result after creating Pine Harbor Test Customer. Person and operating-company names are fictional example data.
Before you start
Use an authorized test environment with SuiteScript, SuiteFlow, script and file access, workflow access, and permission to create a customer. The same employee owns the script and workflow and performs this test. Both stay in Testing. Limit the deployment audience to that tester, and leave Execute as Admin cleared. In OneWorld, use an authorized subsidiary and satisfy the customer form's other required fields.
The prepared file only reads the context and logs three values. The recording selects that file; it does not show source-code editing. Save this code as return_workflow_result.js before starting:
/**
* @NApiVersion 2.1
* @NScriptType WorkflowActionScript
*/
define(['N/runtime', 'N/log'], (runtime, log) => {
const onAction = (context) => {
const roleId = runtime.getCurrentScript().getParameter({
name: 'custscript_action_role'
});
log.debug({ title: 'Role parameter', details: roleId });
log.debug({ title: 'Record type', details: context.newRecord.type });
log.debug({ title: 'Record ID', details: context.newRecord.id });
return 'READY';
};
return { onAction };
});
01. Create the script and parameter
Open Customization > Scripting > Scripts > New, select the prepared file in Script File, and click Create Script Record. Verify Type = Workflow Action. Name the script Return Workflow Result, use customscript_return_workflow_result as its ID, and keep the tester as Owner.
On Parameters, choose Return Type = Free-Form Text. Add a parameter labelled Role ID, with ID custscript_action_role and Type Free-Form Text. Save the parameter and script, then reopen Parameters to verify both settings. The parameter ID must match the name passed to getParameter in the file.
02. Restrict the testing deployment
Click Deploy Script. Set Applies To = Customer, ID customdeploy_return_workflow_result, Status = Testing, Log Level = Debug, and Execute as Role = Current Role. Keep Deployed checked. Under Audience, select only the testing employee, then save.
Testing limits execution; Debug controls log visibility. Current Role uses the invoking permission context. It does not grant a separate privileged role.
03. Create the workflow and state field
Open Customization > Workflow > Workflows > New. Name it Customer Action Result. Select the Customer base record and Customer subtype where your form shows them. Keep the tester as Owner, choose Release Status = Testing, and enable logging. Keep Keep Instance And History = Only When Testing so the test instance can be inspected.
Use event-based initiation with On Create checked, On View Or Update cleared, and Trigger Type = After Record Submit. Save, name the initial state Capture Result, and save its properties.
In that state's Fields area, choose New State Field. Set Label = Action Result, Type = Free-Form Text, and enable Store Value. Save and confirm the field appears under the state. It is a workflow state field; it does not need a field on the customer form.
04. Map the input and returned value
With Capture Result selected, click New Action and choose Return Workflow Result. Set Trigger On = After Record Submit. In Store Result In, select Action Result (State). Under the action's script parameters, set Role ID using Value Field = User Role, then save.
Reopen the action and verify all three settings. If the custom action is missing, inspect its deployment record type, status, owner and audience. If the destination field is missing, check its state and confirm that its type matches the script's Return Type.
05. Save the customer and verify the result
As the same testing owner, open Lists > Relationships > Customers > New. Create Pine Harbor Test Customer, complete the required form fields, and save once. Open System Information > Workflow History and locate Customer Action Result in Capture Result.
Inspect Options where the form exposes state values. This example shows Action Result: READY. If your form does not expose the value there, open the workflow instance and state details to inspect the stored field.
Open the instance's Log and expand the custom action. The example logs custscript_action_role = 3 and Script result value: READY. Your mapped role value may differ; investigate a blank value before relying on it. This supports the execution check; the stored state value above is the separate output check.
06. Correlate the execution logs
Open Return Workflow Result from the Scripts list and select Execution Log. Match the test time and tester across Role parameter, Record type, and Record ID. Here they show 3, customer, and 7101.
The customer screen displays customer number 1047. The log displays internal record ID 7101. Those identifiers have different purposes; the replay does not expose the internal ID on the customer screen. In your account, verify the saved customer's internal ID through its record URL or an authorized record lookup before concluding that the log belongs to that customer.
The completed check needs both the stored Action Result: READY and execution entries tied to the saved record. If the logs exist but the state value is missing, inspect Return Type, the destination field type, and Store Result In.
Common questions
Can a Workflow Action Script return a value?
Yes. Return the value from the script’s onAction entry point. In this guide, the script returns READY; this is the demonstrated example, not a required value.
What settings must match for the value to be stored?
Set the script’s Return Type and the workflow state field’s Type to Free-Form Text. Then select that state field in the custom action’s Store Result In setting.
Does the destination need to be a field on the customer record?
No. The destination is a workflow state field with Store Value enabled. It does not need to appear on the customer form.
What is the difference between the script parameter and the return value?
The script parameter is an input supplied to the action, such as Role ID. The return value is the script’s output, such as READY, which the action stores in the selected workflow state field.
Where should I verify the stored result?
Check the workflow instance under System Information > Workflow History, then inspect the state values or Options. In the guide’s example, the stored value is Action Result: READY; this check is separate from reviewing the script or workflow logs.
What should I check if the logs show a result but the state field is blank?
Recheck the script’s Return Type, the state field’s type, and the action’s Store Result In selection. Also confirm that the action ran in the expected state and trigger context; an execution log entry alone does not replace verification of the stored state value.