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
chubsubchubsub 

Trigger to update field after update on Approved Locked Record

My goal here is to run a time-based workflow to update the Quote Status 30 days after the Quote as been approved.  It sounds like an easy requirement, when the status is changed to "Approved" via the approval process, a time-based workflow will update the status again 30 days after.  But, a workflow can not set off another workflow, meaning, once the workflow in the approval process that update the status to "Approved", that will not trigger another workflow to set it to another status of "Approved all the way" afterwards.  So,I thought I try a trigger.

 

My thought was to create a trigger to update a checkbox field called Recently_Approved__c when the Status on the Quote changes from "Draft" to "Approved".  Then, a workflow will update the Quote Status again to "Approved all the way" after the Recently_Approved__c checkbox is set to True. So, I created the trigger, and it worked, but only on Before Update, which did not trigger the workflow to update the status to "Approved all the way" when the Recently_Approved__c checkbox was checked via the trigger.

 

My main issue is my trigger is trying to update the Quote record after it has been approved.  So, when the user that needs to approve the record hits approved, a field update in the approval process will update the Status to "Approved", which should trigger the the Recently_Approved__c checkbox to True, but I get this error message:

execution of AfterUpdate caused by: System.FinalException: Record is read-only

 

So, I guess my question is how can I get around this by updating a field via a trigger on a record that is locked via an approval process?

 

Thanks in advance!

Mike@COLMike@COL

Can you provide the code for your trigger?

Ritesh AswaneyRitesh Aswaney

You can't update a record in an After Trigger. You should be able to detect the field update by the approval process final approval actions in a before update trigger.

 

If you must update in an after trigger - you will need to re-query the record and then update. (trigger.new is read-only in an after trigger)

 

eg

Quote[] quotes = new Quote[]{};

for (Quote q : trigger.new ){

quotes,add(new Quote(Id = q.Id, Status = 'Recently Approved');

}

 

if(quotes != null && !quotes.isEmpty()

Database.update(quotes);

chubsubchubsub

Mike@COL: Below is my trigger code, it update the Recently_Approved__c field to True when the Status changes from Draft to Approved:  Like I said, this works with Before Update, but it doesn't set the other workflow, which updates the Status to "Approved all the way" when the Recently_Approved__c is checked.


 

trigger RecentlyApprovedTrigger on Quote (after update) {

List<ID> quoIds=new List<Id>();
for (Id theQ : trigger.oldMap.keySet())
{
Quote oldQ=trigger.oldMap.get(theQ);
Quote newQ=trigger.newMap.get(theQ);
String oldStatus=oldQ.Status;
String newStatus=newQ.Status;
if ( (null!=oldStatus) && ('Draft'==oldStatus) &&
(null!=newStatus) && ('Approved'==newStatus) )
{
newQ.Recently_Approved__c=True;
}
}

}

 

 

 

Ritesh Aswaney:  I tried the example code you provided, but I altered it a little as I am trying to update the Recently_Approved__c checkbox field to True After Update, hoping that it will then set off the workflow I explained above.

 

Here is my alterations, but I am getting an error message:

System.DmlException: Update failed. First exception on row 0 with id {QuoteId}; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, RecentlyApprovedTrigger: maximum trigger depth exceeded Quote trigger event AfterUpdate for {QuoteId}.

 

trigger RecentlyApprovedTrigger on Quote (after update) {

Quote[] quotes = new Quote[]{};
for (Quote q : trigger.new ){
quotes.add(new Quote(Id = q.Id, Recently_Approved__c = TRUE));
}
if(quotes != null && !quotes.isEmpty())
Database.update(quotes);

}

Mike@COLMike@COL

You are causing an infintite loop by updating the quote. You need to add a condition to your loop that will prevent the update from being called again when the trigger is called. Something like this: (See the line marked /*NEW CODE*/

 

trigger RecentlyApprovedTrigger on Quote (after update) {
Quote[] quotes = new Quote[]{};
for (Quote q : trigger.new ){
/*NEW CODE*/if ( q.Recently_Approved__c != TRUE ){
quotes.add(new Quote(Id = q.Id, Recently_Approved__c = TRUE));
}
}
if(quotes != null && !quotes.isEmpty())
Database.update(quotes);
}

 

chubsubchubsub

Thanks Mike, that's a great point, I added your code snippet, and I didn't receive the error message anymore, but it still isnt working the way it should.  

 

It will update the Recently_Approved__c checkbox, but it doesnt set off the workflow to update the Status to "Approved all the way" when going through the approval process.

 

I did a test without the approval step by simply creating the quote and saving it with the status set to Draft.  And then I edited the Status to be Approved and when I saved the record, it worked....the Recently_Approved__c field was checked, which set off the workflow to set the status to "Approved all the way".  I don't understand why it doesn't work via the approval process though. When I click approve, the Recenlty_Approved__c field is checked via the trigger, but the other workflow doesn't get set off.

Mike@COLMike@COL

What are the criteria on your workflow?

chubsubchubsub

Recently_Approved__c = True

 

I'm using the evaluation critieria as When a record is created, or when a record is edited and did not previously meet the rule criteria.  I'm using this because I will eventually be adding the Time-Dependent Workflow.

Mike@COLMike@COL

Hmmm. The next step is to turn on debug logging then recreate the problem. If you don't find the problem yourself, you can post the log here and I will take a look at it.

Ritesh AswaneyRitesh Aswaney

I'm hoping :

- As the final approval action of your Approval, you have the field update, and a 'Record Unlock' action configured

- At the start of your test, you reset Recently_Approved__c = False, so that the trigger sets this to true and sets off the workflow

steve456steve456

take off the line "Database.update(quotes);"

 

 

check once it will work

 

 

other wise take off dat line"Database.update(quotes);" and write the trigger on before update

 

 

 

 

chubsubchubsub

Mike@COL : I don't understand why I need to debug it, the trigger works as it should, the issue is with the workflow not being fired after the Recently_Approved__c is checked.  

 

Ritesh Aswaney: Thanks for those suggestions, but I tried them all and more and I still can not get the workflow to fire after the the Recently_Approved__c is checked via the approval process.  Everything still works fine when I update the record without the approval process.  I thought unlocking the record would do the trick, but that's not the issue, it's still the fact that a workflow can not be fired from a field update in an approval process...which I think is weird.

 

steve456:  I tried your suggestion by removing that line and trying the Before Update, but didn't have any luck.

 

Thanks for everyones help with this

Mike@COLMike@COL

The debug logs will include the workflow rule evaluation and execution, so you may be able to figure out why the workflow isn't firing.

chubsubchubsub

Thanks MIke, can you see anything in this log?

 

07:37:59.115 (1115316000)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Quote
07:37:59.151 (1151792000)|WF_RULE_EVAL_BEGIN|Assignment
07:37:59.151 (1151816000)|WF_RULE_EVAL_BEGIN|Response
07:37:59.151 (1151827000)|WF_RULE_EVAL_BEGIN|Workflow
07:37:59.151 (1151857000)|WF_CRITERIA_BEGIN|[Quote: testquo0 0Q0U0000000Gw6b]|Recently Approved|01QU0000000Tab7|ON_CREATE_OR_TRIGGERING_UPDATE
07:37:59.164 (1164550000)|WF_RULE_FILTER|[Quote : Recently Approved equals true]
07:37:59.164 (1164566000)|WF_RULE_EVAL_VALUE|0
07:37:59.164 (1164576000)|WF_CRITERIA_END|false
07:37:59.164 (1164595000)|WF_CRITERIA_BEGIN|[Quote: testquo1 0Q0U0000000Gw6c]|Recently Approved|01QU0000000Tab7|ON_CREATE_OR_TRIGGERING_UPDATE
07:37:59.164 (1164615000)|WF_RULE_FILTER|[Quote : Recently Approved equals true]
07:37:59.164 (1164622000)|WF_RULE_EVAL_VALUE|0
07:37:59.164 (1164628000)|WF_CRITERIA_END|false
07:37:59.164 (1164642000)|WF_SPOOL_ACTION_BEGIN|Workflow
07:37:59.164 (1164652000)|WF_ACTION| None
07:37:59.164 (1164662000)|WF_RULE_EVAL_BEGIN|Escalation
07:37:59.164 (1164669000)|WF_RULE_EVAL_END
07:37:59.164 (1164734000)|WF_ACTIONS_END| None
07:37:59.164 (1164745000)|CODE_UNIT_FINISHED|Workflow:Quote
07:37:59.182 (1182544000)|DML_END|[189]
07:37:59.963 (1182598000)|CUMULATIVE_LIMIT_USAGE
07:37:59.963|LIMIT_USAGE_FOR_NS|(default)|

Mike@COLMike@COL

It doesn't appear that your criteria, " Recently Approved equals true" is evaluating to true. Where is the rest of the log? There should be trace from the trigger firing right above this.

chubsubchubsub

Here's the entire log, I created a test method to cover the trigger:

 

Debug Log:

23.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
13:08:38.318 (318942000)|EXECUTION_STARTED
13:08:38.318 (318977000)|CODE_UNIT_STARTED|[EXTERNAL]|01pU00000015D0E|TestRecentlyApprovedTrigger.myTest
13:08:38.319 (319024000)|METHOD_ENTRY|[2]|01pU00000015D0E|TestRecentlyApprovedTrigger.TestRecentlyApprovedTrigger()
13:08:38.319 (319052000)|METHOD_EXIT|[2]|TestRecentlyApprovedTrigger
13:08:38.319 (319499000)|SOQL_EXECUTE_BEGIN|[5]|Aggregations:0|select id from profile where name='Standard User'
13:08:38.328 (328500000)|SOQL_EXECUTE_END|[5]|Rows:1
13:08:38.338 (338997000)|DML_BEGIN|[11]|Op:Insert|Type:User|Rows:1
13:08:38.434 (434418000)|DML_END|[11]
13:08:38.519 (519413000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:1
13:08:38.628 (628193000)|ENTERING_MANAGED_PKG|arlUniserv
13:08:38.665 (665972000)|SOQL_EXECUTE_BEGIN|[83]|Aggregations:0|SELECT arlUniserv__Apex_Key__c,arlUniserv__Category__c,arlUniserv__Key__c,arlUniserv__Value__c
FROM arlUniserv__Configuration_Dictionary__c limit 10000
13:08:38.707 (707971000)|SOQL_EXECUTE_END|[83]|Rows:163
13:08:38.713 (713591000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:08:38.729 (729331000)|SOQL_EXECUTE_END|[54]|Rows:0
13:08:38.729 (729552000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:08:38.753 (753660000)|DML_END|[64]
13:08:38.754 (754000000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:08:38.755 (755854000)|SOQL_EXECUTE_END|[54]|Rows:0
13:08:38.755 (755983000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:08:38.773 (773842000)|DML_END|[64]
13:08:38.774 (774738000)|DML_END|[15]
13:08:38.775 (775178000)|DML_BEGIN|[18]|Op:Insert|Type:Contact|Rows:1
13:08:38.820 (820269000)|ENTERING_MANAGED_PKG|arlUniserv
13:08:38.820 (820856000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:08:38.823 (823043000)|SOQL_EXECUTE_END|[54]|Rows:0
13:08:38.823 (823178000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:08:38.840 (840763000)|DML_END|[64]
13:08:38.841 (841182000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:08:38.843 (843136000)|SOQL_EXECUTE_END|[54]|Rows:0
13:08:38.843 (843317000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:08:38.866 (866372000)|DML_END|[64]
13:08:38.867 (867395000)|DML_END|[18]
13:08:38.882 (882956000)|DML_BEGIN|[24]|Op:Insert|Type:Opportunity|Rows:1
13:08:38.928 (928592000)|CODE_UNIT_STARTED|[EXTERNAL]|01qU0000000LLVt|ManageOpportunities on Opportunity trigger event BeforeInsert for [new]
13:08:38.928 (928734000)|METHOD_ENTRY|[1]|01pU0000000WIsQ|ManageOpportunities.ManageOpportunities()
13:08:38.929 (929519000)|METHOD_EXIT|[1]|ManageOpportunities
13:08:38.929 (929544000)|METHOD_ENTRY|[6]|01pU0000000WIsQ|ManageOpportunities.beforeInsert(LIST<Opportunity>)
13:08:38.929 (929794000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:0|Select Id, AccountId, Daily_Tracking_Number__c from Opportunity where CreatedDate = TODAY
AND Daily_Tracking_Number__c != null AND AccountId IN :accId order by Daily_Tracking_Number__c Desc
13:08:38.933 (933772000)|SOQL_EXECUTE_END|[17]|Rows:0
13:08:38.933 (933972000)|METHOD_EXIT|[6]|01pU0000000WIsQ|ManageOpportunities.beforeInsert(LIST<Opportunity>)
13:08:38.978 (934007000)|CUMULATIVE_LIMIT_USAGE
13:08:38.978|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 25 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:08:38.978|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:08:38.978 (934007000)|CUMULATIVE_LIMIT_USAGE_END

13:08:38.934 (934181000)|CODE_UNIT_FINISHED|ManageOpportunities on Opportunity trigger event BeforeInsert for [new]
13:08:38.969 (969951000)|DML_END|[24]
13:08:38.970 (970232000)|DML_BEGIN|[30]|Op:Insert|Type:Quote|Rows:1
13:08:39.010 (1010396000)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Quote
13:08:39.032 (1032812000)|WF_RULE_EVAL_BEGIN|Assignment
13:08:39.032 (1032836000)|WF_RULE_EVAL_BEGIN|Response
13:08:39.032 (1032846000)|WF_RULE_EVAL_BEGIN|Workflow
13:08:39.032 (1032869000)|WF_CRITERIA_BEGIN|[Quote: testquotestoptrigger 0Q0U0000000GwCf]|Recently Approved|01QU0000000Tab7|ON_CREATE_OR_TRIGGERING_UPDATE
13:08:39.044 (1044516000)|WF_RULE_FILTER|[Quote : Recently Approved equals true]
13:08:39.044 (1044531000)|WF_RULE_EVAL_VALUE|0
13:08:39.044 (1044537000)|WF_CRITERIA_END|false
13:08:39.044 (1044555000)|WF_SPOOL_ACTION_BEGIN|Workflow
13:08:39.044 (1044564000)|WF_ACTION| None
13:08:39.044 (1044577000)|WF_RULE_EVAL_BEGIN|Escalation
13:08:39.044 (1044583000)|WF_RULE_EVAL_END
13:08:39.044 (1044629000)|WF_ACTIONS_END| None
13:08:39.044 (1044636000)|CODE_UNIT_FINISHED|Workflow:Quote
13:08:39.053 (1053263000)|DML_END|[30]
13:08:39.097 (1053315000)|CUMULATIVE_LIMIT_USAGE
13:08:39.097|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 5 out of 150
Number of DML rows: 5 out of 10000
Number of script statements: 31 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:08:39.097|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:08:39.097 (1053315000)|CUMULATIVE_LIMIT_USAGE_END

13:08:39.053 (1053363000)|CODE_UNIT_FINISHED|TestRecentlyApprovedTrigger.myTest
13:08:39.053 (1053374000)|EXECUTION_FINISHED

 

chubsubchubsub

I found this thread and am thinking this is not going to be possible:

http://boards.developerforce.com/t5/General-Development/Workflow-Rule-triggered-by-an-Approval-Process-field-update/m-p/142900/highlight/true#M33024

 

Workflow isn't permitted to trigger workflow, so one way to get around this:

 

1) Approval process updates the Approved checkbox

2) After update trigger fires and calls an asynchronous Apex method

3) Asynch apex method updates the record

4) 2nd Workflow rule fires, sending the email alert

Mike@COLMike@COL

Accordint to the log, your triigger, called RecentlyApprovedTrigger, is not being executed. There shoudl be a CODE_UNIT_STARTED entry followed by the name of your trigger, like this one: "CODE_UNIT_STARTED|[EXTERNAL]|01qU0000000LLVt|ManageOpportunities on Opportunity trigger event BeforeInsert for [new]". Check your test class and make sure the trigger is active.

chubsubchubsub

OK,  I added an update method to my test class, here's the log where it's being executed

 

Debug Log:

23.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
13:37:53.397 (397593000)|EXECUTION_STARTED
13:37:53.397 (397637000)|CODE_UNIT_STARTED|[EXTERNAL]|01pU00000015D0E|TestRecentlyApprovedTrigger.myTest
13:37:53.397 (397698000)|METHOD_ENTRY|[2]|01pU00000015D0E|TestRecentlyApprovedTrigger.TestRecentlyApprovedTrigger()
13:37:53.397 (397738000)|METHOD_EXIT|[2]|TestRecentlyApprovedTrigger
13:37:53.397 (397845000)|SOQL_EXECUTE_BEGIN|[5]|Aggregations:0|select id from profile where name='Standard User'
13:37:53.407 (407279000)|SOQL_EXECUTE_END|[5]|Rows:1
13:37:53.407 (407448000)|DML_BEGIN|[11]|Op:Insert|Type:User|Rows:1
13:37:53.530 (530238000)|DML_END|[11]
13:37:53.530 (530358000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:1
13:37:53.706 (706025000)|ENTERING_MANAGED_PKG|arlUniserv
13:37:53.741 (741896000)|SOQL_EXECUTE_BEGIN|[83]|Aggregations:0|SELECT arlUniserv__Apex_Key__c,arlUniserv__Category__c,arlUniserv__Key__c,arlUniserv__Value__c
FROM arlUniserv__Configuration_Dictionary__c limit 10000
13:37:53.792 (792314000)|SOQL_EXECUTE_END|[83]|Rows:163
13:37:53.798 (798702000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:37:53.815 (815366000)|SOQL_EXECUTE_END|[54]|Rows:0
13:37:53.815 (815752000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:37:53.848 (848141000)|DML_END|[64]
13:37:53.848 (848513000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:37:53.850 (850898000)|SOQL_EXECUTE_END|[54]|Rows:0
13:37:53.851 (851062000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:37:53.870 (870183000)|DML_END|[64]
13:37:53.871 (871010000)|DML_END|[15]
13:37:53.871 (871098000)|DML_BEGIN|[18]|Op:Insert|Type:Contact|Rows:1
13:37:53.917 (917641000)|ENTERING_MANAGED_PKG|arlUniserv
13:37:53.918 (918027000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:37:53.920 (920080000)|SOQL_EXECUTE_END|[54]|Rows:0
13:37:53.920 (920218000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:37:53.942 (942328000)|DML_END|[64]
13:37:53.942 (942630000)|SOQL_EXECUTE_BEGIN|[54]|Aggregations:0|SELECT Id,arlUniserv__Linked_SObject__c,arlUniserv__Type__c
FROM arlUniserv__SObject_ID__c
WHERE arlUniserv__Linked_SObject__c IN :shortRecIds AND arlUniserv__Type__c = :checkType
13:37:53.944 (944635000)|SOQL_EXECUTE_END|[54]|Rows:0
13:37:53.944 (944766000)|DML_BEGIN|[64]|Op:Insert|Type:arlUniserv__SObject_ID__c|Rows:1
13:37:53.964 (964508000)|DML_END|[64]
13:37:53.965 (965397000)|DML_END|[18]
13:37:53.965 (965559000)|DML_BEGIN|[24]|Op:Insert|Type:Opportunity|Rows:1
13:37:54.010 (1010255000)|CODE_UNIT_STARTED|[EXTERNAL]|01qU0000000LLVt|ManageOpportunities on Opportunity trigger event BeforeInsert for [new]
13:37:54.010 (1010381000)|METHOD_ENTRY|[1]|01pU0000000WIsQ|ManageOpportunities.ManageOpportunities()
13:37:54.011 (1011232000)|METHOD_EXIT|[1]|ManageOpportunities
13:37:54.011 (1011254000)|METHOD_ENTRY|[6]|01pU0000000WIsQ|ManageOpportunities.beforeInsert(LIST<Opportunity>)
13:37:54.011 (1011490000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:0|Select Id, AccountId, Daily_Tracking_Number__c from Opportunity where CreatedDate = TODAY
AND Daily_Tracking_Number__c != null AND AccountId IN :accId order by Daily_Tracking_Number__c Desc
13:37:54.014 (1014589000)|SOQL_EXECUTE_END|[17]|Rows:0
13:37:54.014 (1014799000)|METHOD_EXIT|[6]|01pU0000000WIsQ|ManageOpportunities.beforeInsert(LIST<Opportunity>)
13:37:54.159 (1014830000)|CUMULATIVE_LIMIT_USAGE
13:37:54.159|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 25 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.159|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.159 (1014830000)|CUMULATIVE_LIMIT_USAGE_END

13:37:54.014 (1014995000)|CODE_UNIT_FINISHED|ManageOpportunities on Opportunity trigger event BeforeInsert for [new]
13:37:54.047 (1047050000)|DML_END|[24]
13:37:54.047 (1047245000)|DML_BEGIN|[30]|Op:Insert|Type:Quote|Rows:1
13:37:54.090 (1090130000)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Quote
13:37:54.116 (1116968000)|WF_RULE_EVAL_BEGIN|Assignment
13:37:54.116 (1116993000)|WF_RULE_EVAL_BEGIN|Response
13:37:54.117 (1117004000)|WF_RULE_EVAL_BEGIN|Workflow
13:37:54.117 (1117034000)|WF_CRITERIA_BEGIN|[Quote: testquotestoptrigger 0Q0U0000000GwCk]|Recently Approved|01QU0000000Tab7|ON_CREATE_OR_TRIGGERING_UPDATE
13:37:54.130 (1130923000)|WF_RULE_FILTER|[Quote : Recently Approved equals true]
13:37:54.130 (1130942000)|WF_RULE_EVAL_VALUE|0
13:37:54.130 (1130950000)|WF_CRITERIA_END|false
13:37:54.130 (1130969000)|WF_SPOOL_ACTION_BEGIN|Workflow
13:37:54.130 (1130979000)|WF_ACTION| None
13:37:54.130 (1130990000)|WF_RULE_EVAL_BEGIN|Escalation
13:37:54.130 (1130996000)|WF_RULE_EVAL_END
13:37:54.131 (1131080000)|WF_ACTIONS_END| None
13:37:54.131 (1131088000)|CODE_UNIT_FINISHED|Workflow:Quote
13:37:54.140 (1140886000)|DML_END|[30]
13:37:54.140 (1140933000)|DML_BEGIN|[31]|Op:Update|Type:Quote|Rows:1
13:37:54.158 (1158983000)|CODE_UNIT_STARTED|[EXTERNAL]|01qU0000000LRdb|RecentlyApprovedTrigger on Quote trigger event AfterUpdate for [0Q0U0000000GwCk]
13:37:54.159 (1159255000)|DML_BEGIN|[11]|Op:Update|Type:Quote|Rows:1
13:37:54.173 (1173000000)|CODE_UNIT_STARTED|[EXTERNAL]|01qU0000000LRdb|RecentlyApprovedTrigger on Quote trigger event AfterUpdate for [0Q0U0000000GwCk]
13:37:54.317 (1173130000)|CUMULATIVE_LIMIT_USAGE
13:37:54.317|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 38 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.317|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.317 (1173130000)|CUMULATIVE_LIMIT_USAGE_END

13:37:54.173 (1173194000)|CODE_UNIT_FINISHED|RecentlyApprovedTrigger on Quote trigger event AfterUpdate for [0Q0U0000000GwCk]
13:37:54.179 (1179127000)|DML_END|[11]
13:37:54.323 (1179168000)|CUMULATIVE_LIMIT_USAGE
13:37:54.323|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 38 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.323|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.323 (1179168000)|CUMULATIVE_LIMIT_USAGE_END

13:37:54.179 (1179220000)|CODE_UNIT_FINISHED|RecentlyApprovedTrigger on Quote trigger event AfterUpdate for [0Q0U0000000GwCk]
13:37:54.179 (1179959000)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Quote
13:37:54.189 (1189441000)|WF_RULE_EVAL_BEGIN|Assignment
13:37:54.189 (1189472000)|WF_RULE_EVAL_BEGIN|Response
13:37:54.189 (1189490000)|WF_RULE_EVAL_BEGIN|Workflow
13:37:54.189 (1189520000)|WF_CRITERIA_BEGIN|[Quote: testquotestoptrigger 0Q0U0000000GwCk]|Recently Approved|01QU0000000Tab7|ON_CREATE_OR_TRIGGERING_UPDATE
13:37:54.189 (1189573000)|WF_RULE_FILTER|[Quote : Recently Approved equals true]
13:37:54.189 (1189589000)|WF_RULE_EVAL_VALUE|1
13:37:54.189 (1189598000)|WF_CRITERIA_END|true
13:37:54.200 (1200296000)|WF_SPOOL_ACTION_BEGIN|Workflow
13:37:54.200 (1200455000)|WF_FIELD_UPDATE|[Quote: testquotestoptrigger 0Q0U0000000GwCk]|Field:Quote: Status|Value:All the way Approved|Id=04YU0000000PSjt|CurrentRule:Recently Approved (Id=01QU0000000Tab7)
13:37:54.200 (1200485000)|WF_ACTION| Field Update: 1;
13:37:54.200 (1200499000)|WF_RULE_EVAL_BEGIN|Escalation
13:37:54.200 (1200506000)|WF_RULE_EVAL_END
13:37:54.213 (1213268000)|CODE_UNIT_STARTED|[EXTERNAL]|01qU0000000LRdb|RecentlyApprovedTrigger on Quote trigger event AfterUpdate for [0Q0U0000000GwCk]
13:37:54.357 (1213508000)|CUMULATIVE_LIMIT_USAGE
13:37:54.357|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 41 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.357|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.357 (1213508000)|CUMULATIVE_LIMIT_USAGE_END

13:37:54.213 (1213607000)|CODE_UNIT_FINISHED|RecentlyApprovedTrigger on Quote trigger event AfterUpdate for [0Q0U0000000GwCk]
13:37:54.221 (1221882000)|WF_ACTIONS_END| Field Update: 1;
13:37:54.221 (1221892000)|CODE_UNIT_FINISHED|Workflow:Quote
13:37:54.228 (1228717000)|DML_END|[31]
13:37:54.373 (1228841000)|CUMULATIVE_LIMIT_USAGE
13:37:54.373|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 1 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 41 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.373|LIMIT_USAGE_FOR_NS|arlUniserv|
Number of SOQL queries: 5 out of 100
Number of query rows: 163 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 4 out of 150
Number of DML rows: 4 out of 10000
Number of script statements: 412 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

13:37:54.373 (1228841000)|CUMULATIVE_LIMIT_USAGE_END

13:37:54.228 (1228901000)|CODE_UNIT_FINISHED|TestRecentlyApprovedTrigger.myTest
13:37:54.228 (1228912000)|EXECUTION_FINISHED

 

Mike@COLMike@COL

It looks like your workflow is executing. This is the behavior I see in the log:

 

RecentlyApprovedTrigger Enter
    DML update on opportunity
        RecentlyApprovedTrigger Enter
        RecentlyApprovedTrigger Exit
        Workflow Quote Enter
            Field update
            RecentlyApprovedTrigger Enter
            RecentlyApprovedTrigger Exit
        Workflow Quote Exit
RecentlyApprovedTrigger Exit

 

 

That looks ok to me. Am I missing something?

chubsubchubsub

Well, it does execute fine when the record isn't being updated through the approval process.  When I click edit and save in the UI, it updates the Recenlty_Approved__c checkbox, which in turn sets the workflow off to update the status to "Approved all the way".  But, when I go through the approval process and approve the record, the trigger will fire and update the Recently_Approved__c checkbox, but the workflow does not get set off.  

Mike@COLMike@COL

Ok. So turn on debug, then execute the approval process in the UI. Compare the logs to see where they differ.