Basically, I want to have validation rules run when a step in an approval process is approved. I would like the rule to take into account which step triggered the rule, so that each step can have different requirements for approval. Is this possible? Thanks!
-
unless you're trying to prevent the approver from picking incorrect values, theres no point in a validation rule to control the field updates by the process, because it will behave as configured.– techtrekkerCommented Oct 15, 2012 at 19:44
-
I don't think I followed your comment. For example, I want to make sure that the Operations team member does not 'Approve' their step in the process without having already input an Account Number into the appropriate field. Does that make sense?– jackerman09Commented Oct 15, 2012 at 19:46
-
okay i get it. so you want the approval process to stamp the step number on the record as an approval action. Then have a validation rule which says if Step 2 & AccountNumber is blank return an error.– techtrekkerCommented Oct 15, 2012 at 19:52
-
Right, that's exactly what I'm looking for. One of the issues that I'm trying to address in creating this process is to avoid people passing along incomplete documents, and now it looks like, even with this system, I can't prevent this from happening.– jackerman09Commented Oct 15, 2012 at 19:56
2 Answers
A custom field for Step Number, or the Status field you were referring to
So on each Approval Step, say Step 1 Have an Approval Action to update the field to Step 1, indicating that Step 1 is approved. Have a validation rule which summarises the data requirements for approval
OR(
AND(Text(Status__c) = 'Step 1', ISBLANK(AccountNumber__c)), // Step 1 Approval Check
AND(Text(Status__c) = 'Step 2', ISBLANK(SomeOtherField__c) // Step 2 Approval Check
)
This will return an error to the Approver in each step if they haven't supplied the required information before approving. (The validation rule will be triggered by the Process attempting a Field Update on Approval)
CORRECTION :
That might not work. login.salesforce.com/help/doc/en/approvals_considerations.htm says 'Field updates don’t evaluate custom validation rules on fields.' :/ So this may not be possible to do
Don't know if an addError via a trigger will be any different.
-
1That might not work. login.salesforce.com/help/doc/en/approvals_considerations.htm says 'Field updates don’t evaluate custom validation rules on fields.' :/ So this may not be possible to do. Commented Oct 15, 2012 at 20:04
-
Unfortunately, after testing this, it did not prevent me from approving the step. If I try to edit the record, it does prevent me from saving it, but it is likely that if a user forgets to update this step, they will never edit the record, so the validation rule would be completely overlooked. Commented Oct 15, 2012 at 20:04
-
Thats correct, that is what the documentation seemed to suggest, as I've stated above. So I would think its not possible. Unless we try to see what a trigger does with an addError on the Record. Commented Oct 15, 2012 at 20:06
-
Hmm, ok, I'm not sure if this project is worthy of a trigger at this point, but I'll explore it a little to see if anything comes of it. Thanks again! Commented Oct 15, 2012 at 20:09
-
One last suggestion, wondering what happens if you make the presence of a value (eg AccountNumber for Step 2) as a precondition for each of the following steps. It will probably follow the 'Else Reject' Path and the request would end up getting rejected, dont know if that works for you. Commented Oct 15, 2012 at 20:11
Validation rules wont work... handle this using trigger. Step 1: Update field using approval actions Step 2: write a trigger and validate the record fields.