Approval Process Field Update Formula Issue?

Question:
I need help creating a formula for an Approval Process to update the Pending Approver field upon initial submission. The requirements are as follows:
- The field update depends on the Opportunity Record Type. If the record type is one of two specific types, the Pending Approver should be set to one of two managers.
- If the submitter’s ManagerId matches certain criteria, the Pending Approver should update to another set of managers.
- Finally, if the submitter’s LastName is a specific value, the Pending Approver should update to a designated manager.
Here is the formula I attempted, which is not working as expected:
IF(
Opp_Record_Type__c = "*" && $User.ManagerId <> "*",
"Courtney Palladino",
IF(
Opp_Record_Type__c = "*" && $User.ManagerId <> "*",
"AM Manager",
IF(
Opp_Record_Type__c = "*",
"Michelle Gedney",
IF(
$User.LastName = "Palladino" || $User.LastName = "Gedney",
"Haydee Gamboa & Frank Amendola",
""
)
)
)
)
The issue is that the formula appears to return results prematurely, preventing it from properly evaluating the conditions in the desired sequence.
Answer:
The problem lies in the order of operations within the formula. Salesforce formulas operate in a “first match wins” manner, similar to firewall rules. The formula stops processing as soon as it encounters a condition that evaluates to true. This means you need to arrange the formula from the most specific conditions to the least specific ones.
Join CRS Info Solutions, a leading institute for Salesforce training in Kolkata. Sign up for a free demo session today!!!
Here’s a revised formula that should work as intended:
IF(
/* Check for specific last names first (most specific condition) */
$User.LastName = "Palladino" || $User.LastName = "Gedney",
"Haydee Gamboa & Frank Amendola",
IF(
/* Check for record type and ManagerId conditions */
(Opp_Record_Type__c = "Rec Type 1" || Opp_Record_Type__c = "Rec Type 2") && $User.ManagerId <> "value1",
"Courtney Palladino",
IF(
(Opp_Record_Type__c = "Rec Type 1" || Opp_Record_Type__c = "Rec Type 2") && $User.ManagerId <> "value2",
"AM Manager",
IF(
Opp_Record_Type__c = "Rec Type 1" || Opp_Record_Type__c = "Rec Type 2",
"Michelle Gedney",
/* Default value if no conditions match */
""
)
)
)
)
Explanation:
This revised formula orders the conditions based on specificity:
- It first checks for specific LastName values, as these are the most restrictive conditions.
- It then evaluates the Opportunity Record Type and ManagerId conditions.
- Finally, it falls back to the less specific conditions, ensuring all possibilities are considered in the correct sequence.
If you have further requirements or edge cases, feel free to share them, and the formula can be adjusted accordingly.
Accelerate Your Salesforce Career in Kolkata
Elevate your Salesforce skills with expert-led Salesforce training in Kolkata, designed for both beginners and professionals. Gain practical experience through real-world projects and master cloud-based CRM solutions with guidance from certified instructors. Unlock new career opportunities and become a Salesforce expert with comprehensive, hands-on learning!
CRS Info Solutions is a leading Salesforce Training in Kolkata, offering a comprehensive, real-time project-based curriculum. Our courses cover Salesforce Admin, Developer, Integration, Marketing Cloud, CPQ, and Lightning Web Components (LWC). With expert instructors providing hands-on training, we ensure you’re equipped for real-world challenges. Join us to become a certified Salesforce professional and kickstart your career.
Enroll now for a free demo at CRS Info Solutions, Kolkata..!!