How can I add additional Conditions to a Workflow formula - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Minhaj_Developer ArifinMinhaj_Developer Arifin 

How can I add additional Conditions to a Workflow formula

I have the following workflow formula which is working on a custom object called Receipt

And( Is_Posted__c  = true,  Is_Refund__c  = false,
CONTAINS ( Business_Group__r.Name , "ILCF"))


Fields on the Receipt object are: 
  • Is Posted (checkbox) 
  • Is Refund (checkbox) 

Fields related to the Receipt object are: 
  • Business Group (lookup) 
  • Item (lookup) 

And( Is_Posted__c  = true,  Is_Refund__c  = false,
CONTAINS ( Business_Group__r.Name , "ILCF"))


In the above formula I am saying that if the Receipt checkbox field 'Is Posted' is checked and the 'Is Refund' is not checked, AND if the associated Business Group has the words ILCF, an email should be sent. 

Additionally I want to add the following conditions: 

if the Business Group does not Contain ILCF and the Item Name is: ABC 100, or ABC 50, or ABC 25, or ABC 15 then the email shold be sent. 

Can you please help me complete this formula. The incomplete part is written underlined: 

And( Is_Posted__c  = true,  Is_Refund__c  = false,
CONTAINS ( Business_Group__r.Name , "ILCF"))

and if the business group does not contain ILCF and the related item's name is ABC 100, or ABC 50, or ABC 25, or ABC 15 or ABC 5 then also send the email. 

Please note: I want the first line to be true for all conditions. 
Best Answer chosen by Minhaj_Developer Arifin
Tony TrinhTony Trinh
If you need the checkbox requirements for both scenarios you can try this as well:
AND(
Is_Posted__c  = true,  
Is_Refund__c  = false,
OR(
CONTAINS ( Business_Group__r.Name , "ILCF"),
AND(
NOT(CONTAINS ( Business_Group__r.Name , "ILCF")),
CASE(Item__r.Name,
"ABC 100",1,
"ABC 50",1,
"ABC 25",1,
"ABC 15",1,
"ABC 5",1,
0) = 1)
)
)

All Answers

Tony TrinhTony Trinh
Hi Minhaj,

You can use a CASE function to lay out all the specific values and see if the CASE function result equals any of those values. Try this out:
And( Is_Posted__c  = true,  Is_Refund__c  = false,
CONTAINS ( Business_Group__r.Name , "ILCF"),
CASE(Item__r.Name,
"ABC 100",1,
"ABC 50",1,
"ABC 25",1,
"ABC 15",1,
"ABC 5",1,
0) = 1)
Minhaj_Developer ArifinMinhaj_Developer Arifin
Thanks Tony, I am trying this out right now. Will update you. 
Andrew FragiasAndrew Fragias

Hi Minhaj,

Given you would like the Item__r.Name criteria to apply only if the Business_Group__r.Name Does not contain ILCF then you should use the below formula:

OR(AND(Is_Posted__c  = true,  Is_Refund__c  = false,
       CONTAINS ( Business_Group__r.Name , "ILCF")
      ),
   AND(NOT(CONTAINS ( Business_Group__r.Name , "ILCF")),
       CASE(Item__r.Name,
            "ABC 100",1,
            "ABC 50",1,
            "ABC 25",1,
            "ABC 15",1,
            "ABC 5",1,
          0) = 1
	   )
  )
Minhaj_Developer ArifinMinhaj_Developer Arifin
Thank you Andrew I will try this one and update you both. 
 
Tony TrinhTony Trinh
Ah yes, rereading your requirement, mine is not correct. ++Andrew's solution looks like it'll work.
Tony TrinhTony Trinh
If you need the checkbox requirements for both scenarios you can try this as well:
AND(
Is_Posted__c  = true,  
Is_Refund__c  = false,
OR(
CONTAINS ( Business_Group__r.Name , "ILCF"),
AND(
NOT(CONTAINS ( Business_Group__r.Name , "ILCF")),
CASE(Item__r.Name,
"ABC 100",1,
"ABC 50",1,
"ABC 25",1,
"ABC 15",1,
"ABC 5",1,
0) = 1)
)
)
This was selected as the best answer
Shivam KumarShivam Kumar
Hi ,
You have to use the case funcation for this formula.
AND(
Is_Posted__c  = true,  
Is_Refund__c  = false,
OR(
CONTAINS ( Business_Group__r.Name , "ILCF"),
AND(
NOT(CONTAINS ( Business_Group__r.Name , "ILCF")),
CASE(Item__r.Name,
"ABC 100",1,
"ABC 50",1,
"ABC 25",1,
"ABC 15",1,
"ABC 5",1,
0) = 1)
)
)

Please try this and implement it and let me know.

Thanks