I have created flow + Process Builder to do a lookup relationship Count on parent object. My issues is I have a validation rule which fires when user try to deleted last child record from the related list. The validation rule is firing as an error. I don't know how to catch this error and display it in the page. There should not be any visualforce page is my requirement.

trigger JobApplicationTrigger on Job_Application__c (after delete) {
        for(Job_Application__c jobapp : Trigger.old)
           Map<String, object> param= new Map<String,object>();
           Flow.Interview.DeleteJobAppRec_flow flow = new Flow.Interview.DeleteJobAppRec_flow(param);
    catch(DMLException err)
      new Job_Application__c().addError('You got an Error :'+err);   

I got a work around. I don't know is it a right approach but it solved my problem. I am checking the validation condition is before trigger if condition is not satisfied i am throwing an error using addError() method so that Flow is not executed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.