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
naveen darshanalanaveen darshanala 

when do we use trigger over workflow?

Anthony McDougaldAnthony McDougald
Hello Naveen,
Hope that your day is off to an amazing start. Best practices for Salesforce development is to use the simplest tool required for the job. APEX is the last thing you want to use out of your developer toolbox as it requires lots of testing and a change set to deploy. Below is a list of when to use which tool for the job on a basic level. Please let us know if you have any other questions and have a blessed day.
Workflow Rule - You have a business need that requires the evaluation of one criteria
Process builder - You have a business need that requires the evaluation of multiple criterion
Approval Process - You have a business need that requires the approval of someone else to be completed
Flow - You have a business need that requires a user's input in order to be completed (very dynamic)
APEX (Triggers or Class) - You have an advance business need that can't be fulfilled by any of the previous said tools

Best regards,
Anthony McDougald​​​​​​​
Team NubesEliteTeam NubesElite
Hi Naveen,
Workflow
Workflow is automated process that fired an action based on Evaluation criteria and rule criteria.
We can access a workflow across the object.
We cannot perform DML operation on workflow
We cannot query from database
workflows will only helpful to update the same object or master object in custom master-detail relationships.
Workflow is inbuilt functionality and used on single objects or master-detail
Workflow can work only after some action.
Trigger
Trigger is a piece of code that executes before or after a record is inserted or updated.
We can access the trigger across the object and related to that objects
We can use 20 DML operations in one trigger.
We can use 20 SOQL’s from data base in one trigger.
Trigger can work across objects and also you can query or DMLs operation.
Trigger is used for complex business process where multiple Object's need to be handle.
Trigger can be used before and after some action.




Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this assolution if your problem resolved
Deepali KulshresthaDeepali Kulshrestha
Hi Naveen,

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)We can not perform Dml operation in workflowWe cannot query from database.
 
4:-- Trigger can work across objects and where in you can query the object as well as you can do DMLs.
 
 
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 objectWe can use 20 Dml operations 
in trigger. Trigger can be used to invoke a webserive.

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


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Ajay K DubediAjay K Dubedi
Hi Naveen,


If you want to know more about Trigger and workflow, please read below- 


1. Workflow is point and clicks which doesn't need any coding. When you want to take action (email, task, field update or outbound message) for the same object or from Child to parent object, you can use Workflow rules.

2. Trigger: It's a programmatic approach and event-driven (insert, update, merge, delete). You can call it an advanced version of Workflow.

Trigger works across all the objects.
You can create a new record through trigger which is not possible through a workflow.



For more information, refer these links-

https://www.quora.com/What-is-the-difference-between-trigger-and-workflow-in-salesforce
https://salesforce.stackexchange.com/questions/26929/workflows-vs-triggers


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com