All about workflow rule , limitation and important points with example

Workflow Rule 

Workflow is a force platform business logic engine that allows us to automatically send email alerts, assign tasks, field updates based on rules that we define.

– Defined trigger criteria based on your business requirements
– Evaluated when record is created, when created/updated, OR when created/updated and did not previously meet trigger criteria
– When trigger criteria is met workflow actions, such as email alerts, tasks, field updates, or outbound messages are generated

To get started using workflow rules, click
• Setup | Create| Workflow & Approvals | Workflow Rules



Workflow action in Salesforce :
  • Task Alert
  • Email
  • Field Update
  • Outbound message



#1 Workflow Task:
Assign task to a user

#2 Email Alert
Used to generate email from the workflow

#3 Field Update 
https://help.salesforce.com/apex/HTViewHelpDoc?id=workflow_field_update_considerations.htm&language=en

#4 Outbound Messages: 
Send a configurable API message to designed listener.

http://www.jdope.com/blog/test-salesforce-workflow-outbound-messages-with-putsreq-com/
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_om_outboundmessaging.htm
http://www.infallibletechie.com/2012/11/outbound-messaging-in-salesforce.html
http://clicksandcode.blogspot.in/2012/01/test-your-workflow-outbound-message.html


Time-Dependent Workflow

Time-Dependent Workflow gives you the ability to
– execute time-sensitive actions before or after any date on the record
– perform a series of actions at various points in time
– use the Workflow Queue to manage all pending actions Use Time-Dependent workflow to
– send an email reminder to an account team if a high-value opportunity is still open ten days before the close date
– notify the VP of sales if a high value opportunity close date is fast approaching and it has not been closed
– pro-actively notify support rep if an open case with Platinum Support SLA has not been worked for a period of time and take action before the case  escalates


Time-Dependent Workflow – Considerations


Maximum of 10 time triggers per rule
Maximum of 40 actions (10 x 4 types) per time trigger, and 80 actions per workflow rule
Workflow default user must be set up before creating time-based rules
Precision limited to hours or days
Cannot convert leads with time-dependent actions in the Workflow Queue
Time triggers cannot be added to or removed from activated workflow rules
Not possible to create a time-dependent action associated to a rule with a trigger type of Every time the record is created or updated

Time-Dependent Workflow Limitations:

Time triggers don’t support minutes or seconds.
Time triggers can’t reference the following:
  • DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
  • Formula fields that include related-object merge fields.
You can’t add or remove time triggers if:

  • The workflow rule is active.
  • The workflow rule is deactivated but has pending actions in the queue.
  • The workflow rule evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
  • The workflow rule is included in a package.

Important questions related to time based workflow/ workflow rule :

Difference between WF and trigger :

Workflow                 
Automated and fires on base on criteria and rule
Can access across object'
No DML 
no query from DB

Trigger
piece of code works after before and after record insert update delete undelete merge
available through all related and direct object
20 DML operation


#1 Criteria at which time based doesn't trigger ?
Created and every time it is edited

#2 When do you can't add a time dependent  action ?
Workflow rule is active
Workflow rule is inactive but have pending action
when rule is created and every time it is edited
in package

#3 We have a time based workflow , and there is action to be executed. If we deactivate the workflow schedule action will be remove or be inside the queue ?
Active inside the queue

#4 We have time based workflow and there is action to be executed. Can we delete the flow ?
No

#5 How to clear time based workflow queue
Make criteria False
Removing Schedule action from queue

#6 If a record meets WF criteria for some time based workflow action , The action goes to queue . Later before execution , Criteria changes . What happens next ?

Time based WF removed from the queue.

There is a time based workflow which will update one of the fields if the criteria meet. User submits the record with valid criteria, workflow triggered so that the field update is queued in the 'time based flow' queue which will fire after one day. If the user modifies the record which is submitted before the scheduled date, after modification, a record criterion is not meeting. Whether the field will be updated or not in schedule date?

It won't trigger in the schedule date because if we modify the record to not meeting criteria that queued field update will be removed from the 'time based flow' queue.

# . For the same scenario explained in the above question what happens when we deactivate or modify the criteria of the workflow to different criteria? Whether the field will be updated or not in schedule date?
Yes, It will trigger in scheduled date.

#. Scenario: There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object, if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?
Ans: It won't fire. To fire wf2 we should enable 'Re-evaluate Workflow Rules' checkbox of the field update which is there in wf1.

#. What is recursive workflow rule? How to avoid recursive workflow rules?
When we enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule, due to this field update other workflow rules on the same object will be fired if the entry criteria of those workflow rules satisfied.

Incase, in other workflow rules also if we enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update recursive workflow rules will come in some scenarios.

We can take two steps to avoid recursive workflow rules -

For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option, we can avoid recursive workflow rules.
If you don't enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.


# Imp Note :

One important reference that i want to include is comparing the working of  validation rule in both process builder and workflow and how to overcome them using flow . Thanks to Johan Yu

ref as well as answer :

http://www.simplysfdc.com/2016/08/salesforce-validation-rule-in-workflow.html 







Comments

Popular posts from this blog

Custom Setting in Salesforce

Action tags in VisualForce Salesforce