Saturday, July 13, 2019

Setting the Project Start Date using a Custom Action Script on a Workflow

The Project Start Date is not available on the Workflow. To set the Project Start Date using other date values on the Opportunity record, you can create a custom action script on a workflow. The workflow needs to be implemented on the Opportunity record. Here is a sample code that can be used as a guide:

 

function setDate()

{

                var jobId = nlapiGetFieldValue('job');        

                var oppDate = nlapiGetFieldValue('expectedclosedate'); //used the Expected Close Date

                var jobRec = nlapiLoadRecord('job', jobId);

                jobRec.setFieldValue('startdate', oppDate);

                nlapiSubmitRecord(jobRec);

}

 

Create a new Workflow Action Script and upload the JS file with the code above. Remember the name of the newly created script.

 

To create the workflow:

 

1.       Navigate to  Customization > Scripting > Workflows > New

2.       Copy the settings below.

·         Name: Set Date WorkFlow

·         Record Type: Opportunity

·         Release Status: Released

·         Enable Logging: <checked>

·         Event Based: <selected>  

·         On Create: <checked>

·         On Update: <checked>

·         Trigger Type: Before Record Submit

3.       Click Save

4.       Create a new state

5.       Enter a name for the state

6.       Click Save

7.       Click the New Action button

8.       Select the action with the name of the Workflow Action Script created above

9.       Set the Trigger on Entry

10.   On the Condition, select Visual Builder

11.   Click the button for the Edit Condition Button

12.   Add the Job (Main) for the Field column and set the Compare Type to Not Empty. 

13.   Click Add then Save

14.   Click Save

 

No comments:

Post a Comment