You need to sign in to do that
Don't have an account?

After Update Trigger Not Firing After Workflow Field Update
Hello!
When an order is created in our org, it automatically submits into an approval process about 7 minutes after creation.
When the approval process is initiated, there is a field update that occurs to fill in the date/time of submission.
I have a trigger that should unlock the record when an update occurs, but it is not firing during the above mentioned automation.
It works perfectly when I manually edit the record.
Here is my code. Am I missing something to make it work when there's a worflow action triggered update?
I'm not a developer, so I don't know much.
trigger Unlock_Order_Pending_Approval on Order (after update) {
//Get records to unlock
List<order> orderList = [SELECT Id From Order WHERE EffectiveDate = TODAY];
//Check locked records
List<order> orderLockList = new List<Order>();
for(Order c :orderList){
if(Approval.isLocked(c.id)){
orderLockList.add(c);
}
}
//Unlock record
if(!orderLockList.isEmpty()){
//Unlock records
List<Approval.UnlockResult> ulrList = Approval.unlock(orderLockList, false);
// Iterate through each returned result
for(Approval.UnlockResult ulr : ulrList) {
if (ulr.isSuccess()) {
//Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked account with ID: ' + ulr.getId());
}
else {
//Operation failed, so get all errors
for(Database.Error err : ulr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Order fields that affected this error: ' + err.getFields());
}
}
}
}
}
When an order is created in our org, it automatically submits into an approval process about 7 minutes after creation.
When the approval process is initiated, there is a field update that occurs to fill in the date/time of submission.
I have a trigger that should unlock the record when an update occurs, but it is not firing during the above mentioned automation.
It works perfectly when I manually edit the record.
Here is my code. Am I missing something to make it work when there's a worflow action triggered update?
I'm not a developer, so I don't know much.
trigger Unlock_Order_Pending_Approval on Order (after update) {
//Get records to unlock
List<order> orderList = [SELECT Id From Order WHERE EffectiveDate = TODAY];
//Check locked records
List<order> orderLockList = new List<Order>();
for(Order c :orderList){
if(Approval.isLocked(c.id)){
orderLockList.add(c);
}
}
//Unlock record
if(!orderLockList.isEmpty()){
//Unlock records
List<Approval.UnlockResult> ulrList = Approval.unlock(orderLockList, false);
// Iterate through each returned result
for(Approval.UnlockResult ulr : ulrList) {
if (ulr.isSuccess()) {
//Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked account with ID: ' + ulr.getId());
}
else {
//Operation failed, so get all errors
for(Database.Error err : ulr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Order fields that affected this error: ' + err.getFields());
}
}
}
}
}


When the approval process is initiated, does the field update happen on the order object? Are your system debugs getting printed in the logs?