0

We have a bypass process when certain emails are sent. I would like to add conditions to the process and I can't seem to get it in a syntax the PB likes.

    AND
($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Bypassed__c, CONTAINS 
($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Profiles__c,$Profile.Name))

These are the two conditions I'd like to add to these criteria

([EmailMessage].Parent.Status CONTAINS "TR/CR",
[EmailMessage].Subject CONTAINS "_TR_CR_")

I've tried adding it within the other condition and it says Syntax error "Missing ')'

AND ($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Bypassed__c, CONTAINS ($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Profiles__c,$Profile.Name), 
([EmailMessage].Parent.Status CONTAINS "TR/CR",
[EmailMessage].Subject CONTAINS "_TR_CR_"))

When I add this I get "Extra Email Message.Parent.Status", but I added it in the formula builder so I know the syntax is correct.

AND ($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Bypassed__c, CONTAINS ($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Profiles__c,$Profile.Name)) 
[EmailMessage].Parent.Status CONTAINS "TR/CR",
[EmailMessage].Subject CONTAINS "_TR_CR_"

Any pointers to documentation or clues as to how to add this would be appreciated.

1 Answer 1

1

There's some good resources:

enter image description here

There's three things within your example that is off:

  1. Parenthesis - if you want all conditions met, make sure they're all within the AND function
AND (
    ..everything here...
)
  1. Email Status is a picklist field and CONTAINS works on text. You'll need to convert the field value into text using TEXT().
  2. Your original formula used CONTAINS correctly (but your additions did not) and the same format/syntax applies even if using a field instead of a custom metadata value.

CONTAINS should be in the format of CONTAINS(text, compare_text) . If that text is a field, then it's just CONTAINS(fieldName, compare_text).

AND(
$CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Bypassed__c,
CONTAINS($CustomMetadata.Process_Builder_Bypass__mdt.Email_Auto_Update_Provided_To_Customer.Profiles__c, $Profile.Name),
CONTAINS(TEXT([EmailMessage].Parent.Status), "TR/CR"),
CONTAINS([EmailMessage].Subject, "_TR_CR_")
)
3
  • Thank you so much for your response, the syntax works, but the [EmailMessage].Parent.Status field throws this error. The formula expression is invalid: Field Email Message is a picklist field. Picklist fields are only supported in certain functions.
    – afandre
    Commented Jul 27, 2021 at 22:20
  • Edited my answer to include that. That field is a picklist field so you need to convert its value to text to use in contains (which expects text) like so CONTAINS(TEXT([EmailMessage].Parent.Status), "TR/CR"), Commented Jul 27, 2021 at 22:27
  • Thank you that was the field I needed.
    – afandre
    Commented Jul 28, 2021 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .