0

In my Org I have Custom_Object_A__c and Custom_Object_B__c. Custom_Object_A__c has a Lookup field to Contact and another Lookup field to Custom_Object_B__c. Custom_Object_B__c also has a Lookup to Contact.

I have a Trigger on Custom_Object_A__c which fires on Insert that looks at the two Lookup fields, if the Lookup to Contact is null, and the lookup to Custom_Object_B__c is populated, then I populate Custom_Object_A__c's Contact field with the value that is set in Custom_Object_B__c.

I am trying to move this functionality to the Process Builder. What I have so far...

  1. Custom_Object_A__c: Only when a record is created.
  2. Criteria: No criteria—just execute the actions!
  3. Immediate Actions: Update Record that started the Process.
  4. Criteria for updating records: Updated records meet all conditions

    • Lookup to Contact is null Boolean true
    • Lookup to Custom_Object_B__c is null Boolean false.
  5. Set new field values for the records you update

    • Lookup to Contact
    • Type: Reference
    • Custom_Object_B__c.Contact ID

Criteria Immediate Action

As best I can tell this should ONLY set the Contact Lookup on Custom_Object_A__c if on creation the Contact Lookup is null AND the Custom_Object_B__c Lookup is NOT null.

However when I try creating a test record for Custom_Object_A__c with the Contact Lookup filled, and the Custom_Object_B__c null I get an error

The record couldn’t be saved because it failed to trigger a flow

I also get an email stating

The flow failed to access the value for myVariable_current.Custom_Object_B__c.Contact__c because it hasn't been set or assigned.

I don't understand why it's even trying to look for this relationship?

Any ideas as to why this is happening?

  • Hi @Doug, on your criteria, you've specified that the Contact lookup should be null before it gets processed. But on your test record, you have Contact lookup filled for Custom_Object_A__c, which means that it won't get processed. Does your Custom_Object_B__c has Contact field populated? can you paste a picture of the process that you've built possible. – Sean Soriano Feb 22 '16 at 19:56
  • @SeanSoriano I've added pictures per your request. – dBeltowski Feb 22 '16 at 21:08
  • @SeanSoriano "But on your test record, you have Contact lookup filled for Custom_Object_A__c, which means that it won't get processed." I don't want this rule to process it in such a case. The problem is that the rule IS TRYING to process it, but since Custom_Object_B__c is not populated it is causing an error. – dBeltowski Feb 22 '16 at 21:10
  • have you tried moving your action criteria on the criteria component(diamond shape)? – Sean Soriano Feb 22 '16 at 21:24
  • @SeanSoriano I haven't done that yet because the "Set Department" Immediate Action doesn't have the same criteria. I was hoping to avoid needing two Processes for this functionality. – dBeltowski Feb 22 '16 at 21:29
1

I would move your criteria to the criteria diamond. In your case, since you need to have set department fire for every record, you'll need two branches to handle this.

  1. The first criteria will handle your criteria for Set Contact, so Contact is null, and Custom_Object_B__c.Contact__c is not null. Your immediate action will be "Set Contact" and "Set Department."
  2. The second criteria will fire with no criteria, this will catch all records that need to be updated with only the "Set Department" action.
  • I'm going to accept this as an answer as it is a valid workaround that solves my problem. However I consider it to be sub-optimal as it requires me to create the "Set Department" action twice. – dBeltowski Feb 23 '16 at 16:18

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.