You need to sign in to do that
Don't have an account?
Parikshit Sarkar 14
Can someone explain me what should be the answer? Thanks.
A custom field Exec_Count_c of type Number is created on an Account object. An account record with value of "1" for a: Exec_Count_c is saved.
A workflow field update is defined on the Exec_Count_c field, to increment its value every time an account record is created or updated. The following trigger is defined on the account:
trigger ExecOrderTrigger on Account (before insert, before update, after insert, after update){ for (Account accountInstance: Trigger.New){ if (Trigger . isBefore) { accountInstance Exec_Count_c += 1; } System. debug (accountInstance.Exec_Count_c); } }
A workflow field update is defined on the Exec_Count_c field, to increment its value every time an account record is created or updated. The following trigger is defined on the account:
trigger ExecOrderTrigger on Account (before insert, before update, after insert, after update){ for (Account accountInstance: Trigger.New){ if (Trigger . isBefore) { accountInstance Exec_Count_c += 1; } System. debug (accountInstance.Exec_Count_c); } }
In the above scenerio if the Exec_Count_c value is zero while inserting. So after the record is saved to database it will be 3. For each update the count will be incremented by 3.
One increment for before update/insert.
second increment for workflow update
third increment will again come for trigger.
Please find the ordedr of excution for more information.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
Can you please let the community what is needed. You have a workflow and trigger. Do you need which one to use?
Thanks,
I encountered a situation where both are in use. I need to know what should be the output in this case.
In the above scenerio if the Exec_Count_c value is zero while inserting. So after the record is saved to database it will be 3. For each update the count will be incremented by 3.
One increment for before update/insert.
second increment for workflow update
third increment will again come for trigger.
Please find the ordedr of excution for more information.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
If this solution helps, Please mark it as best answer.
Thanks,
Exec_Count_c initial value is 0 and once record save to Database it will be 3 and increase by 3 after every count.
1st increment for before update/insert(UPSERT).
2ND INCREAMENT USING WORKFLOW UPDATE.
3RD BY TRIGGER.
FOLLOW ORDER OF EXECTION (BELOW LINK):
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
IF MY ANSWER HELP YOU MARK IT AS BEST ANSWER.
THANKS