function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sudhakar ReddySudhakar Reddy 

Trigger vs Workflow vs Validations

 

 Can any one explain with one small examples when to use trigger,workflow and Validations?

Why I am asking this questions is,same functionality can be achieved by using trigger,workflow and validation.So I got confusion.Please explain when to use Trigger ,workflow and Validations?

priyanka.mv26priyanka.mv26

Validation rule can be used if you want to validate the field values in that particular records which you are creating/updating. It will not work in delete operations. 

 

Workflows are used to do actions like creating task, Sending outbound messages, send emails and field update. In workflows, we cannot update field in another related object 

 

Triggers are used to do any complex logics.

 

For example,

1. If you want to delete a only if the record name is 'okToDelete', then you cannot validate this through validation rule. here you can use before delete trigger to validate and allowing the record to delete

 

2. In workflows, you have to specify the receipient email address while you create the email alert itself. you cannot determine the receipient dynamically according to the field values. In this case, trigger will help.

 

3. Let me consider a parent object called 'Candidate' and child object 'Job application', while updating a field in parent object 'Candidate', If i want to update a field in the child, i cannot do this using field update in workflows. but a trigger will work in this case.

 

Simply all the logics that cannot be achieved declaratively (validation rules, workflows), we can do that using a trigger

Sudhakar ReddySudhakar Reddy

I understood this question from your comments.

subbu123.pbt@gmail.comsubbu123.pbt@gmail.com

2 step .

Ple write the query how we get email Dyanmically  by using trigger  ?