Thursday, November 15, 2018

Set Field Display Type action for Multiselect fields in Workflow

When executing actions on Client Trigger (Before User Edit, Before Field Edit, After Field Edit, After Field Sourcing, Before User Submit), you must apply the action to trigger on the changing of one or more fields. All fields of the record accessible via SuiteFlow (Workflow Manager) will be seen on the Client Fields except for multiselect fields when creating a Set Field Display Type Action.

The script shown below can serve as an alternate solution if you want to use a multiselect field as a client field to change a display type of a field. The Client script seen mimics a Set Field Display Type action on 'After Field Edit' trigger where it disables a custom field (custrecord01) when 'Selection1' is not selected on a custom multiselect field. 

1. Upload and save the script as a Client SuiteScript to your NetSuite Account.

function FieldChanged(type,name)
{
 var context = nlapiGetContext();
 var userEmail = context.getEmail();

       //customselect01 is the multiselectfield & Selection1 is one of the values
       if ((name == 'custmultiselect01') && (nlapiGetFieldText('custmultiselect01') == "Selection1"))  
 {
                       // custrecord01 which is a custom record is not diabled when Selection1 is selected on the multiselect field
                       nlapiDisableField('custrecord01', false);

 }
 else
 {
                        // custrecord01 which is a custom record is diabled when Selection1 is selected on the multiselect field
                        nlapiDisableField('custrecord01', true);
 }

}

 

2. Deploy the Script to the correct record & Save 

No comments:

Post a Comment