function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deanna Aaron 11Deanna Aaron 11 

Update a field based on specific criteria missing in workflow?

I’m setting up an automatic “Thank You” email that will send to our donors when an opportunity closes.
The workflow rule refers to specific criteria.
Examples:
  1. IF the primary contact email IS NOT BLANK
  2. IF the opportunity is less than or equal to $250
  3. IF the stage equals “posted”
There are other criteria as well.
If a user checks the box, the email will only send to the donor IF all of the criteria have been met.
If all of the criteria hasn’t been met, I can create a workflow rule/process builder to insert a value in a new field that I’m going to create, indicating which criteria hasn’t been met.

For example:

IF “Email Permission” box is checked AND the primary contact email IS BLANK, update field to:
Primary contact email is blank
What I’m wondering is…if multiple criteria are not met – how would I know?
Maybe we can append values or maybe there’s another solution?

Thank you for your help.
 
Best Answer chosen by Deanna Aaron 11
Gokula KrishnanGokula Krishnan
Hi Deanna,

Instead of Field update using workflow, you can go with formula field, 
Create a Formula field with Text data type and use 'if' condition to return the values.

Eg: if(isblank(primary_contact__c), 'Primary contact email is blank','')
+'&'+if(stage != 'posted' , 'stage is not equal to Posted','')
+'&'+if(NOT(amount <= 250 ), 'Amount is not less than or equal to $250','')

Result : If all the creteria is not satisfied, than
Primary contact email is blank & stage is not Posted & Amount is not less than or equal to $250,
if anyone of the creteria is not satisfied, then respective values will shown

Thanks.

If it helps you, please mark is as best answer, so it will be helpful for other developers.

All Answers

Gokula KrishnanGokula Krishnan
Hi Deanna,

Instead of Field update using workflow, you can go with formula field, 
Create a Formula field with Text data type and use 'if' condition to return the values.

Eg: if(isblank(primary_contact__c), 'Primary contact email is blank','')
+'&'+if(stage != 'posted' , 'stage is not equal to Posted','')
+'&'+if(NOT(amount <= 250 ), 'Amount is not less than or equal to $250','')

Result : If all the creteria is not satisfied, than
Primary contact email is blank & stage is not Posted & Amount is not less than or equal to $250,
if anyone of the creteria is not satisfied, then respective values will shown

Thanks.

If it helps you, please mark is as best answer, so it will be helpful for other developers.
This was selected as the best answer
Deanna Aaron 11Deanna Aaron 11
Thank you so much, Gokula! This was absolutely helpful. After inserting this into a formula field, it brought up a few questions.

1. How do I use this for picklist condition?
For example, I used: +'&'+if(NOT(ISPICKVAL(StageName, "Posted")), "Stage is Not Posted")
Received Syntax Issue---
Error: Incorrect number of parameters for function 'if()'. Expected 3, received 2

2. Is there a way to only generate the text in my formula field if a checkbox field is checked?

Thank you, again. You have helped us a lot!
Gokula KrishnanGokula Krishnan
Hi Deanna,

1. IF statement contains 3 statements, Syntax: IF(Condititon, TRUE, FALSE).
Try out this : +'&'+if(NOT(ISPICKVAL(StageName, 'Posted')), 'Stage is Not Posted','')

2. Yes, IF( checkboxField__c, 'Values for TRUE', 'Values for FALSE')

Thanks,