+ Start a Discussion
rcravenrcraven 

Validation of fields during an Approval Process Step, Is this Possible?

The original submitter doesn't have access to certain fields, let's say PO number and License Number.  These fields need to be updated during a specific reviewal/approval step.

 

Is it possible to validate that these fields have been filled in during a specific approval step?  And if not dissallow approval?

 

 

Any help is very appreciated. 

SiriusBlackOpSiriusBlackOp

You can do this in a trigger as follows.  There might be an easier built in way, but this works.

 

trigger tgrValidateApproval on YourObjectNameHere (before update) { for (Integer i = 0; i < trigger.new.size(); i++) { if (trigger.old[i].ApprovalStatus != trigger.new[i].ApprovalStatus && trigger.new[i].ApprovalStatus == "Approved") { //here is a validation check - add more of these if needed, and maybe even build up a single error msg for all. if (trigger.new[i].Some_Value__c == null){ trigger.new[i].addError("Approval Failed because SomeValue is blank."); } } } }

 

 

Message Edited by SiriusBlackOp on 06-30-2009 01:48 PM
rcravenrcraven

Agree this would work for a custom object, however, we are using the Salesforce Approval WF. 

 

The API does not allow triggers to be create on the ProcessInstanceStep object.  Ideally, we would like to dissallow the approval.

 

However, if the approval step updates a field on a custom object, we could write an update trigger like your peudo code, but that is after the fact it's been approved, and we would need to rollback to the previous approver.  Yuck!

 

Do you know how to rollback to the previous approval step using Apex?  Is this possible? 

 

 

 

 

 

 

Message Edited by rcraven on 07-01-2009 07:37 AM
Message Edited by rcraven on 07-01-2009 07:39 AM
Message Edited by rcraven on 07-01-2009 07:39 AM