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
skk169skk169 

Triggers nd workflows

Hi,
1) When we use Triggers and when we use workflows? wat is the diff b/w them? I knw wat r workflows, but dnt know abt Triggers.
kindly assist me.
Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,


A trigger means programming in APEX (a java look-a-like) and you can do things with a trigger that no Workflow actions can do.

Worksflow rules however, allow you to do a lot of useful thinsg with zero programming, like updating fields and sending out emails based on rules. Very neat.
Workflow is used for Update,Send Email, Craeting Task based on the criteria you specified. Previously you can use workflow when you want something to be happening on the same object but with Spring 12 you can use this with cross object like formula field. You cannot update a lookup field using workflow similarly you will find more . So by using Cross workflow you can work on to different object but there must be a relation between them.
On the other hand you can write trigger on a particular object and so something on other object even if there is no relation between these object. For example suppose you want whenever a Account is inserted all the Custom Object Record should be updated while you don’t have any relation between account and custom object. Try the below as reference:
Trigger accountTest on account(after insert)
{
List<customObject__c> cus=[select id,name from customObject__c limit 1000];
Update cus;
}
You will know more when you will work on this.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,


A trigger means programming in APEX (a java look-a-like) and you can do things with a trigger that no Workflow actions can do.

Worksflow rules however, allow you to do a lot of useful thinsg with zero programming, like updating fields and sending out emails based on rules. Very neat.
Workflow is used for Update,Send Email, Craeting Task based on the criteria you specified. Previously you can use workflow when you want something to be happening on the same object but with Spring 12 you can use this with cross object like formula field. You cannot update a lookup field using workflow similarly you will find more . So by using Cross workflow you can work on to different object but there must be a relation between them.
On the other hand you can write trigger on a particular object and so something on other object even if there is no relation between these object. For example suppose you want whenever a Account is inserted all the Custom Object Record should be updated while you don’t have any relation between account and custom object. Try the below as reference:
Trigger accountTest on account(after insert)
{
List<customObject__c> cus=[select id,name from customObject__c limit 1000];
Update cus;
}
You will know more when you will work on this.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
Rajesh SriramuluRajesh Sriramulu

Hi

 

With Trigger we can insert,delete, update  no.of records at a time based on events 

 

(1) Workflow : inbuilt functionality, used on single obj /master-detail

 

 (2) Trigger : Used for complex business process in which multiple Obj can handle. 

 

Trigger can work across objects and where in you can query the object as well as you can do DMLs

 

But workflows will only helpful to update the same object or master object in custom master-detail relationships.

 

 

SRS