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
Sreenivasulu AdipudiSreenivasulu Adipudi 

Visual Flow before events vs Apex trigger before events

Hi Everyone,

I have the following scenario:
Update the Status__c field when Is_Active__c field value is changed.
  • As of now, we are using an apex trigger to update the field by comparing trigger.old and trigger.new values.
  • If wanted to use the visual flow, I have to get the old value from database and compare it with the new value.
  • It may cause another SOQL query.
My question in this scenario is,
Which is the best approach either using apex trigger or visual flows.

Thanks in advance.
Sreenivasulu A
Best Answer chosen by Sreenivasulu Adipudi
AnudeepAnudeep (Salesforce Developers) 
Hi Sreenivasulu - You can achieve this using a process builder

I recommend checking the Sample Scenarios section in this Trailhead module

User-added image

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Sreenivasulu - You can achieve this using a process builder

I recommend checking the Sample Scenarios section in this Trailhead module

User-added image

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep
This was selected as the best answer
Sreenivasulu AdipudiSreenivasulu Adipudi
Hi Anudeep,

Thanks for your quick reply. It is helpful for me.
Updating through process builder will be one more DML operation and It causes to fire the assignment rules, auto-response rules, workflow rules, and other customizations once again.
Because of that, I wanted to update the field values before performing the DML (in before triggers or flows).

Thanks,
Sreenivasulu A.