You need to sign in to do that
Don't have an account?
Warjie
Issue with order of execution of triggers and workflows when DML is fired inside a VF page
Hi, I have read the order of execution from Salesforce (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm) and it seems like contradicting to what I'm getting with my test.
Please see below timeline of events/results of my test:
This is a portion of the code where it sets the status to "Pending" as a default value:
- Is there a way to make the Approval Status to "Awaiting Approval" via workflow with at least minimal change(s)?
Appreciate your response everyone! Thanks!
Please see below timeline of events/results of my test:
- Save button (saveAdjustments method) in a VF page is clicked.
- Inside the code, it sets the Approval Status of Transaction Adjustment (TA) to "Pending".
- It will insert a new TA record.
- Workflow rule will run: Update Case Status on Transaction Adjustment
- Workflow will update the Approval Status of TA to "Awaiting Approval".
- After the TA has been created, I noticed that the TA's Approval Status is now back to "Pending" even though the rule was successfully met.
This is a portion of the code where it sets the status to "Pending" as a default value:
public PageReference saveAdjustments(){ // Set up list for insertion Decimal appLimit = getApprovalAmountLimit(); Decimal secLimit = getSecondApprovalAmountLimit(); list<Transaction_Adjustment__c> taToInsert = new list<Transaction_Adjustment__c>(); for (AdjustmentWrapper item : adjustmentList){ item.ta.Approval_Status__c = pendingStatus; //pendingStatus = 'Pending'Notes:
- I cannot simply comment out the assignment of Approval Status in the code as it is being used in the creation of another record from a different object. Doing so caused me to experience a null reference error.
- I cannot also change the status to "Awaiting Approval" in the code as I don't know the full impact. I;m not the one who created this.
- Is there a way to make the Approval Status to "Awaiting Approval" via workflow with at least minimal change(s)?
Appreciate your response everyone! Thanks!