+ Start a Discussion
Naresh_reddyNaresh_reddy 

1. Difference between Work flow and Trigger? When will you prefer to use each of them explain with an example?

SandhyaSandhya (Salesforce Developers) 
Hi Naresh,

Workflow
But workflows will be only helpful to update the same object or master object in custom master-detail relationships.
You cannot create records
they currently can only result in a task, email, field update, or outbound message
they can only cross objects in a master-detail relationship, from the detail to the master, and only for certain scenarios (all custom to custom objects, some custom to standard objects, and even fewer standard to standard)

https://help.salesforce.com/HTViewHelpDoc?id=workflow_cross_object_field_updates.htm&language=en_US


Example
I suggest you refer this link for example.

http://www.adminhero.com/creating-your-first-workflow-rule/


Trigger

Trigger can work across objects and where in you can query the object as well as you can do DMLs
can do these things, but obviously using code
often needed for roll-up type scenarios where roll up summary fields cannot be used
often needed when a record needs to be created on a different object

Example
I suggest you refer this link for example.
http://www.bedrockdata.com/blog/salesforce.com-sample-trigger-code-how-to-auto-create-an-account-or-any-record-when-adding-a-contact

http://www.salesforcetutorial.com/apex-trigger-create-simple-trigger/

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya

 
NagendraNagendra (Salesforce Developers) 

Hi Naresh,

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.
 
There are several scenarios in which you can't achieve your functionality with workflows......

(1) Workflow : inbuilt functionality, used on single obj /master-detail
 
 (2) Trigger : Used for complex business process in which multiple Obj can handle. 
 
Before  jump  into coding check first is it possible to solve an issue using workflow.

User-added image

Whenever we do DML operations like (insert,update,delete ) then you go for Trigger concept ,but here we cann't do DML operation using Workflow. .Trigger works before and after some actions,Coding is required.    Workflows work only after some actions, Coding is not required.


Please let us know if you require more information.

Kindly mark my solution as the best answer if it helps you.

Best Regards,
Nagendra.P
Naresh_reddyNaresh_reddy
Thanks
Amit Chaudhary 8Amit Chaudhary 8
HI Naresh_reddy,

There are to many post are available for same in google.
Please check below post i hope that will help you
1) https://www.youtube.com/watch?v=hvNQZtld7kk
2) https://success.salesforce.com/answers?id=90630000000gnMfAAI
3) https://developer.salesforce.com/forums/?id=906F0000000AvHRIA0


Workflow
  1. you cannot create records
  2. they currently can only result in a task, email, field update, or outbound message
  3. they can only cross objects in a master detail relationship, from the detail to the master, and only for certain scenarios (all custom to custom objects, some custom to standard objects, and even fewer standard to standard) https://help.salesforce.com/HTViewHelpDoc?id=workflow_cross_object_field_updates.htm&language=en_US
Trigger
  1. can do these things, but obviously using code
  2. often needed for roll-up type scenarios where roll up summary fields cannot be used
  3. often needed when a record needs to be created on a different object
  4. needed to kick off some apex code
  5. many other reasons
User-added image

Let us know if this will help you
 
Kent GreemKent Greem

Thanks for explanation but which apex code should be kicked off?

________________________________________

http://writingatermpaper.com/term-paper-topics/

Naresh_reddyNaresh_reddy
Thanks