3

We have a custom object that can be associated with an account. Since this object type is usually created by an automated process, we'd like to trigger emails to account owners when these objects are created and associated with one of their accounts. Seems like an ideal use case for process builder, right?

Unfortunately I'm coming up against a problem because not all the instances of this object are actually linked to an account. I figure I need to check whether an account is linked before trying to access the account owner's name.

Based on this answer, I've tried the following:

NOT(ISNULL([My_Custom_Object__c].Account__c)) &&
[My_Custom_Object__c].Account__c.Owner.LastName = "SurnameOfAnAccountOwner"

But I'm still having issues. Is there anything glaringly wrong with this?

Unfortunately, I don't receive emails with detailed errors - I only know this isn't working because of generic errors in the automated process that's trying to create the custom object instances.

  • 1
    Second validation is unnecessary since an Account will always have an owner. – Alexander Aeons Torn Jan 26 '17 at 12:46
  • Good call @AlexanderAeonsTorn. Is it possible that this is tripping me up? – Tom Wright Jan 26 '17 at 13:09
  • I don't think so. But its redundant. I also don't understand at all the last validation you're doing there. Could you explain me please? Could it be that this last validation is messing things up avoiding the rule to validate correctly and send the email? Try to just do the first check. and send the email to the account Owner. – Alexander Aeons Torn Jan 26 '17 at 13:16
  • 1
    Oh, okey, then makes sense to leave it there. Try with just those 2 checks and tell me. Put you lastname user on the second check and create a records to test if you receive the email properly. – Alexander Aeons Torn Jan 26 '17 at 13:23
  • 2
    this is covered here: salesforce.stackexchange.com/a/8827/2602 try: NOT(ISBLANK(...)) – cropredy Jan 26 '17 at 18:31
2

For some time now, SFDC has recommended that one use ISBLANK(..) in lieu of ISNULL(..). As Matt Lacey describes, ISNULL behaves differently for text and lookup fields than ISBLANK.

So, rewrite your expression to:

NOT(ISBLANK([My_Custom_Object__c].Account__c)) &&
[My_Custom_Object__c].Account__c.Owner.LastName = "SurnameOfAnAccountOwner"

Things are a bit different in APEX:

  • If field Foo__c.Account__c is a lookup field, then if (foo.Account__c == null) works as expected.

  • If field Foo__c.SomeTextField__c is a field of type Text, then one uses

    if (String.isBlank(f.SomeTextField__c)) 
    

    to handle both null and empty string situations.

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.