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
ArnoldFBArnoldFB 

Interrupt Approval Process to require fields with Trigger, or Visualforce, or Visual Workflow, or......?!?

OK so I've got this approval process. I interrupt approval at one of the intermediate approval steps via trigger to require three custom fields, one of which is a contact lookup. I can't use validation because the record likely won't be edited, just approved so the validation will never fire.  The problem is the error code is a bad user experience.  It's a crappy font, they have to back out and cancel out of the approval to fill in the fields.  it's sub-optimal.  I'd Love to call a visualforce page and have them fill in the fields if any of them are blank but I've read I can't call a VF page from a trigger.  Soooooo.  what to do?  Visual workflow?   Advice welcome. 
I'll post my current trigger which throws the error.  It's clunky as hell, I know.
  Thanks, 

 

trigger ContractRequestTrigger on Contract_Request__c (Before insert, before update, before delete, after insert, after update, after delete) {  
    noTrigger__c settings = noTrigger__c.getInstance(userinfo.getUserId()); 
    Boolean goTrigger = settings.Enable_Triggers__c;    
    if(checkRecursive.runOnce() && goTrigger){
        //trigger to test for these values is needed because a normal validation rule fires after the record is
        //saved so using trigger logic lets us overcome SF order of operations and intervene in the approval
        // process steps.
        if(trigger.isupdate){
            for(Contract_Request__c request : Trigger.new){
            
                //This looks at the request and if both the client signing complete Checbox is true, and the record says
                //we're using docusign for signature, it checks the docusign box.  This functions within the approval process.  
                //The Approval step field updates can't check on the values of the fields, so we have a trigger working in 
                //conjunction with the approaval. 
                system.debug('before the if loop signing complete = '+request.Client_Signing_Complete__c);
                if (request.client_signing_complete__C == True && Request.Using_Docusign_for_Signature__c =='Yes') {
                    Request.DocuSign_Fully_Executed__c = True;         
                }
                // This diasllows asking for Docusign/Formal Signing to begin unless the three fields mentioned are complete.
                if(request.Process_Status__c == 'Draft Approved/Signature Pending' 
                && (request.Using_Docusign_for_Signature__c == null ||
                    request.Who_Signs_First__c              == null ||
                    request.Ultimate_Signee__c              == null )) {
                    request.addError('You must fill in Who Signs First, Ultimate Signee, and Using Docusign Info prior to beginning formal Signing Procedure with the client. Use your browser back button, cancel out of the approval, then fill in all the info and resubmit. Sorry for the trouble');      
                }    
            } 
        } //update trigger section ends here
    }      
}