In NetSuite workflows, it is possible to create and redirect to a record. 

However, there are some limitations to consider.

For example, you cannot create a transaction via Workflow Manager. Another use case is the ability to create a Custom Record with parent-child relationships.

The good news is that, these limitations are addressed by SuiteScript, through a script type called “Workflow Action Scripts”. In this tutorial, we will show you how to create a workflow that creates a record and redirects to that record with the help of Workflow Action Scripts.   

CREATE THE NETSUITE SCRIPT  

  1. Go to Customization > Scripting > Scripts > New.  
  2. Upload the sample script shown below.
  3. Enter a name.
  4. Under Parameters, select “List/Record”, then the Record Type of your choosing. (In my example, I used a custom record).
  1. Click on Save.
  2. Click on Deploy Script.
  3. Select the record type where you deployed your workflow.
  4. Keep the status as “Testing” and save.
/**
 *
 * @NApiVersion 2.x
 * @NScriptType WorkflowActionScript
 * @NModuleScope public
 *
 * Author: LEACC
 */
define(['N/record', 'N/runtime'],
    function(record, runtime) {
        function wfCreateRfQ(scriptContext) {
			
			var currentRecord = scriptContext.newRecord; 
			
			var title = currentRecord.getValue("title");
			
			var recordType = "customrecord_test_record"; 
            var objRecord = record.create({
                type: recordType,
                isDynamic: true
            });
			
			objRecord.setValue({
                    fieldId: "name",
                    value: title
                }); 
				
			objRecord.setValue({
                    fieldId: "custrecord_lcc_text",
                    value: "Test from Workflow"
                }); 
				
            var recordId = objRecord.save({
                enableSourcing: true,
                ignoreMandatoryFields: true
            });
			
			return recordId; 
        }
		
        return {
            onAction : wfCreateRfQ
        }
})

CREATE THE FIELD

You might be wondering, why are we creating a custom field? This is where we’ll store the ID of the created custom record.

There are two ways on how you can store the record. First is by creating a workflow field. You can choose this option if you’re not planning to store the record somewhere for user access. The second one is by creating a custom field that sits on the record type where you’re deploying a workflow. In my example since I used “Task”, I chose to create a CRM field.  

  1. Go to Customization > Lists, Records & Fields > CRM fields.
  2. Enter a name. (eg “Associated Record”)
  3. Select “List/Record” under Type and choose the custom record under “List/Record”.
  4. Click on “Task” under “Applies To”.

CREATE THE WORKFLOW

  1. Go to Customization > Workflow > Workflows > New.
  2. Enter a name and deploy it to the record type of your choosing. (In my example, I chose “Task”)
  3. On the Workflow Summary:
    a. Click on “On View or Update”
    b. Trigger Type = Before Record Load
  4. Click on “New Action”.
  5. Select “Add Button”.
  6. Enter a label and save. (Sample label: “Create Record”)
  7. Click on “New State” button.
  8. Add a transition between State 1 and State 2.
  9. On the “Transition” pop-up > Execute on Button, select the button that you created.
  10. On State 2, click on “New Action”.
  11. Select the workflow action that you deployed (It should display “(Custom)” together with the name). See sample screenshot:
  12. A pop-up window will appear. Scroll down and select the custom field in “Store Result In”.
  13. Add a new state (State 3).
  14. Add a transition between State 2 and State 3.
  15. On State 3, click on “New Action” > “Go to Record”.
  16. On the Go to Record pop-up, change the “Trigger On” to “Entry”.
  17. Under Parameters of the “Go to Record” action, select the custom record under Record Type and choose the custom field (Associated Record) on the “Field”.
  18. Click on “Open in Edit Mode”.
  19. Click on Save.

TEST THE WORKFLOW

You have deployed the script, created the field and configured the workflow. The next thing to do is to test the workflow. Since in my example I used “Task” as the record type, here are my steps:

  1. View any Task record.
  2. Click on “Create Record” button.
  3. Notice that the record redirected to the Custom Record created by the workflow action script.

CEANA TECHNOLOGY is a team of NetSuite experts with IT experience solely dedicated to NetSuite technologies for eight years. We are specialists in NetSuite development and NetSuite SRP. See our project portfolio in this page.

Do you have any questions about the NetSuite SRP feature?

Leave a Reply