[SalesForce] Process Builder Formula Criteria

I have a process builder currently set up to create a case that works fine.

AND(ISCHANGED([Account].HDM_Inactivation_Date__c ),
    NOT(ISNULL([Account].HDM_Inactivation_Date__c )),
    ([Account].LastModifiedBy.ProfileId <> "00eC0000001guvbIAA"),
    ([Account].LastModifiedBy.ProfileId <> "00eC0000001f595IAA"),
    ([Account].LastModifiedBy.ProfileId <> "00eC0000001WdP1IAK"),
    ([Account].LastModifiedBy.ProfileId <> "00eC0000001f8aaIAA"),
    ([Account].LastModifiedBy.ProfileId <> "00eC0000001f448IAA"),
    ([Account].LastModifiedBy.ProfileId <> "00eC00000015nsbIAA")
    )

I needed to add additional criteria where the

'Hotel_Expedia_Id__c' field 
was not blank and the LCM_Active_Flag__c field = to 'Active' or Null

So I wrote this:

AND(ISCHANGED([Account].HDM_Inactivation_Date__c ),
NOT(ISNULL([Account].HDM_Inactivation_Date__c )),
([Account].LastModifiedBy.ProfileId <> "00eC0000001guvbIAA"),
([Account].LastModifiedBy.ProfileId <> "00eC0000001f595IAA"),
([Account].LastModifiedBy.ProfileId <> "00eC0000001WdP1IAK"),
([Account].LastModifiedBy.ProfileId <> "00eC0000001f8aaIAA"),
([Account].LastModifiedBy.ProfileId <> "00eC0000001f448IAA"),
([Account].LastModifiedBy.ProfileId <> "00eC00000015nsbIAA"),
NOT(ISBLANK([Account].Expedia_Hotel_Id__c)),

OR (ISPICKVAL([Account].LCM_Active_Flag__c, 'ACTIVE')),    
        (ISNULL(TEXT([Account].LCM_Active_Flag__c)))    
)

But now the process builder is not firing. Can someone please help me with my formula? The LCM Active Flag field is a picklist field.

Best Answer

It looks like you meant to OR join the last two criteria, but actually it's as if you didn't use OR at all:

AND(
    ...
    OR (ISPICKVAL([Account].LCM_Active_Flag__c, 'ACTIVE')),
    // ^ 1...    ^ 2...                                 ^^ OR IS CLOSED
    (ISNULL(TEXT([Account].LCM_Active_Flag__c))) // <-- always enforced
)

This is a great example of why you should always use indentation to denote logical nesting level.

AND(
    ...,
    OR(
        ISPICKVAL([Account.LCM_Active_Flag__c, 'ACTIVE'),
        ISNULL(Text([Account].LCM_Active_Flag__c)
    )
)

Also don't add parentheses where they are not needed. And don't hard-code Ids. Here is your formula as I would write it:

AND(
    ISCHANGED([Account].HDM_Inactivation_Date__c),
    NOT(ISNULL([Account].HDM_Inactivation_Date__c)),
    [Account].LastModifiedBy.Profile.Name <> "Profile Name 1",
    [Account].LastModifiedBy.Profile.Name <> "Profile Name 2",
    [Account].LastModifiedBy.Profile.Name <> "Profile Name 3",
    [Account].LastModifiedBy.Profile.Name <> "Profile Name 4",
    [Account].LastModifiedBy.Profile.Name <> "Profile Name 5",
    [Account].LastModifiedBy.Profile.Name <> "Profile Name 6",
    NOT(ISBLANK([Account].Expedia_Hotel_Id__c)),
    OR(
        ISPICKVAL([Account].LCM_Active_Flag__c, 'ACTIVE'),
        ISNULL(TEXT([Account].LCM_Active_Flag__c))
    )
)
Related Topic