Friday, 29 April 2022

Workflow

 

Workflow :

Salesforce Workflow is a business logic that evaluates the records as they are created, updated in an object to apply automated process like Assigning Tasks, Emails, Field Update and outbound message sending.

 Different evaluation criteria of workflow?
Created
Created and every time it’s edited
Created and every time it’s edited to meet the subsequently criteria

             What are the different workflow actions available in Salesforce?
             Tasks.
             Email alerts.
             field updates.
            Outbound messages

            What is the difference between Created and every time edited to meet the criteria and Created and            edited  to subsequently meet the criteria?
If we select 'Created and every time edited to meet the criteria' whenever we create a record or edit a record if the criteria of the workflow rule meets then it will trigger every time. If we select 'Created and edited to subsequently meet the criteria' -

While creating the record criteria meets so that workflow will fire and while editing the record again criteria meets workflow won't fire (meeting the criteria to meeting the criteria)
While creating the record criteria doesn't meet so workflow won't fire and while editing the record workflow criteria meets then workflow will fire (not meeting the criteria to meeting the criteria)
Conclusion: Previous state of record should be not meeting criteria and current state of record should be meeting the criteria then only in current state workflow will fire.

What are the types of rule criteria’s?
1.Criteria meet (field - operator - value, if there are multiple criteria’s then in filter criteria we can give conditions like ( 1 or 2) and 3, field to field comparison is not possible, we can't fetch the previous state information of the field )
2.Formula evaluated (we can write formulas with this we can do field to field comparison and we can fetch previous state value of the record)

What is immediate workflow action?
The action which will be performed immediately after the record criteria meets.

What is Time-Dependent Workflow?
 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

Limitations of Time-dependent workflow?
When defining time dependent workflows in salesforce we have to use standard and custom date and date/time fields defined for the object.

We have to specify time using days and hours.
Also add actions to existing time triggers.

In which criteria of a workflow – “time dependent workflow action” cannot be created?
Created, and every time it’s edited.

When you can’t add Time dependent action in Workflow rule?
When workflow rule is active.
When workflow rule is deactivated and has pending actions in the queue.
When the workflow rule criteria of a record is set to: created, and every time it’s edited.
When the workflow rule is included in a package.

How can you monitor future actions of time-based workflow?
setup --> administration set up --> monitoring --> time-based workflow

We have a “Time Based Workflow” and there is Action scheduled to be executed. If we Deactivate the workflow, Scheduled actions will be removed from queue or not?
Even after deactivating the workflow, its action will not be removed. It’s still active in queue and will execute on scheduled time. 

We have “Time Based Workflow” and there is action scheduled to be executed. Can we delete that workflow?

It is not possible to delete the workflow when the workflow is having any pending time dependent actions.

How to clear the Time-based workflow action queue?
Make the criteria false.
Removing scheduled actions from the queue.

While creating workflow on Task, what difference observed on available actions?
While creating workflow on task we cannot find “Send Email” action.

Suppose if a record meets workflow criteria for time-based workflow action, the action goes in queue. Later, before the time-based action is triggered, the same record gets modified, and the criteria previously met is changed and now it does not meet the workflow criteria. What happens to the time-based action placed in Queue? 
In this case, pending action in the time-based workflow will execute on scheduled time and before taking any action, it will check the condition that was given in workflow rule (Rule Criteria), and if condition does not meet, then no action will be taken and simply removed from the queue.

Tell us the things that we can do in workflow and not in the trigger- Time dependent workflow
Workflow vs Process Builder
Process Builder can update any field on any related record, where Workflow can only update some fields on a parent record of a Master-Detail relationship.
Process Builder can perform DML operation, but workflow cannot.

As we know that, in time-based workflow, we can take action based on hour or day? What if I have to take action after 5 minutes of record is created.
This is not possible directly. But we can use here a technique.
Create a formula field on object which will calculate time after 5 min of created date.

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?
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?
Whenever 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.

In case, 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.

A workflow already exists on object. Now user want to add time dependent workflow action to it but not able to get an option to select time dependent action. What might be issue?
OR When The Add Time Trigger button is unavailable?
The evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
The rule is activated.
The rule is deactivated but has pending actions in the workflow queue.

Process Builder

 

Process Builder:

Process builder also allows us to automate the organization’s business processes quickly without writing any code.

Process builder supports three types of processes for automation needs:

  • A record Change – Process starts when a record is created or updated.
  • A Platform event occurs – process starts when platform event message is received.
  • It’s invoked by another process – Process starts when something else, like another process, invokes it.

 

With process builder we can :

  • Create a record of any object type.
  • Update any related record – not just the record or its parent.
  • Use a quick action to create a record, update a record, or log a call
  • Invoke a process from another process
  • Launch a flow—you can’t schedule this action with workflow
  • Send an email
  • Post to Chatter
  • Submit a record for approval
  • Call apex class or flow.
  • Send custom notification
  • QUIP- Create documents, chat rooms, and folders when important events occur

Note : we can create more than one process builder for an object but it is best practice to use one process builder and define multiple processes using conditions.

How can we create time dependent or Scheduled action in process builder?

There are two ways in which we can setup scheduled action in process builder

  • OPTION 1 : When object selection for process builder select “Only when a record is created”
  • OPTION 2 : When object selection for process builder if you select “when a record is created or edited” then on the criteria selection either select “conditions are met” or “Formula evaluates to true” along with Advanced option selection “ Do you want to execute the action only when specified changes are made to the record?”

What is the minimum time we can set to trigger the time dependent actions?

We can set minimum of 1 hours to trigger the time dependent action. This is same for process builder and workflows.

What if we want to trigger the time dependent action after 30 minutes?

It is directly not possible but you can trick salesforce to achieve it. 

Example : Create a formula field that evaluates to datetime  and  write the formula as current datetime minus 30 minutes.  Then create a time dependent workflow that fires 1 hour after the newly created formula field

What are process versions in process builder?

When we first create a process in the process builder it will create it as version 1 and if we modify the same process later then it creates the new version of the process each time we modify the process.

Duplicate id in list

  Error 'System.ListException: Duplicate id in list' in Apex : list  can hold  duplicate values, but if you try to add duplicate  sO...