Tuesday, June 25, 2019

Evaluate Two Custom Fields with Numerical Type using Less than or Greater than on After Field Edit Workflow Trigger

Image


Customer reported that greater / less than (i.e. ">" & "<') functionality does not work correctly because the logic appears to be flawed. As an example, it considers 18 to be a greater number than 122. It appears to be using alphabetical order instead of numerical value.

 

In order to evaluate properly, user should use parseInt function. See sample below:

 

1) Create two custom fields with Integer Number type , go to Customization > List, Records & Fields  > Entity Fields > New
   - Name : Custom Integer 1
   - Type : Integer Number
   - Applied To : Project = checked
   - Display : Subtab = Main , Display Type = Normal
   - Click Save

 

   - Name : Custom Integer 2
   - Type : Integer Number
   - Applied To : Project = checked
   - Display : Subtab = Main , Display Type = Normal
   - Click Save

 

2.) Create Workflow and deploy in Project Record, go to Customization > Workflow Workflows > New
    - Name : Compare Integer
    - Initiation: Event Based
    - Event Definition = On Create , On Update
    - Trigger Type = All
    - Execute as Admin = checked
    - Released Status = Testing
    - Enable Logging = checked

 

3.) Create a State , click New State
    - Name = State 1
    - Click Save

 

4.) On State 1, click New Action > Set Field Value

    - Trigger On = After Field Edit
    - Client Fields = {you can select any field} (e.g Entity Dropdown custom field)
    * On the Condition use Custom Formula to apply the parseInt function. See below:


       parseInt(nlapiGetFieldValue('custentity58'))>=parseInt(nlapiGetFieldValue('custentity59'))


    - Field = Checkbox custom field , Value: Checked = true


5.) Create a Project, go to List > Relationships > Projects > New
    - Set Custom Integer 1 (custentity58) = 18
    - Set Custom Integer 2 (custentity59) = 122

    - Select value on Entity Dropdown custom field
 
Result: Checkbox field is not checked since condition is not met "Custom Integer 1 > Custom Integer 2"

 

 

No comments:

Post a Comment