Thursday, March 5, 2015

Workflow rule field update for users in specific roles

Use Case:

Users belonging to different roles "EU Sales" and "APAC Sales" would like to have a functionality in salesforce to automatically update " Reason" field on leads to "Not responding" when the lead status is changed to " Closed-Not Converted".






For this use case the best recommendation would be to create a field update workflow rule. 
Workflow rules can be used to assign tasks to users,update fields or send emails.

Step1: Create a workflow rule on the lead object. You want the reason field to be updated when a record is created as well as edited to subsequently meet the criteria. Evaluation criteria would be created and every time its edited. 

Step2: Select rule criteria to Formula evaluates to true

Formula:

AND(ISPICKVAL(Status,"Closed: Not Converted"), 
OR($UserRole.Id = "000123456789jji", $UserRole.Id = "0005678786hihyi"))



Let us breakdown the formula

When the lead status ( Picklist value) changes to Closed: Not Converted then the workflow rule should trigger and update the field. The current user changing the lead status should belong to one of the roles. 

AND : Checks whether all the conditions defined in the formula are true and returns true.

(ISPICKVAL(Status,"Closed: Not Converted") : Checks whether lead Status Picklist is closed not converted.

OR($UserRole.Id = "000123456789jji", $UserRole.Id = "0005678786hihyi"))
We are using OR condition because we want the rule to check if the current user belongs to one of the defined roles. 

Note: You can either use $UserRole.Id  "000123456789jji" in the formula or $UserRole.Name " US Sales" both should work in the workflow rule. 




Step3: Create a workflow action on the workflow rule. Specify the field value and the field to be updated. 


Activate your workflow rule and you are done!





No comments:

Post a Comment