+ Start a Discussion
Tom STom S 

Case with nested if statements

To preface my question I"m a newbie so please be patient with me I'm very new to Salesforce.

I need to populate a text field called "Account Folder Name" with one of these values Agent, Carrier, Individual, Support, Client, Prospect or Former Client.  The result of this field will be used to create our folder structure in Egnyte.

My challenge  is under the field "BenefitsGuide__RecordTypeName__c" I have two options "Account_Large_Group" and "AccountSmallGroup" that need to be broken down into "Client" or "Prospect" or "Former Client".  I have looked everywhere and the best I came up with is the following...

CASE(BenefitsGuide__RecordTypeName__c, 
"Account_Broker_Agent", "Agent", 
"Account_Brokerage_Agency", "Agent", 
"Account_Carrier", "Carrier", 
"Account_Groups_of_1", "Individual",
"Account_Individual_Family", "Individual",
"AccountSupport", "Support",

"Account_Large_Group", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", "")))

"AccountSmallGroup", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", "")))

"General"))

My problem is I can't figure out how to get past the syntax error missing ')' so any help will be appreciated.  Oh and "Egnyte_Group_Type__c" is a text field I am pulling data into from a picklist field.  If needed I can use the picklist field directly its name is "BenefitsGuide__Account_Status__c".

Thanks
Best Answer chosen by Tom S
Agustin BAgustin B
Hi, remove the last ) as I think you dont need it, also put a , before "General" and before AccountSmallGroup
Something like this:
CASE(BenefitsGuide__RecordTypeName__c, 
"Account_Broker_Agent", "Agent", 
"Account_Brokerage_Agency", "Agent", 
"Account_Carrier", "Carrier", 
"Account_Groups_of_1", "Individual",
"Account_Individual_Family", "Individual",
"AccountSupport", "Support",

"Account_Large_Group", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", ""))),
"AccountSmallGroup", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", ""))),
"General")

If it helps please like and mark as correct, it may help others.

Good luck.

All Answers

Agustin BAgustin B
Hi, remove the last ) as I think you dont need it, also put a , before "General" and before AccountSmallGroup
Something like this:
CASE(BenefitsGuide__RecordTypeName__c, 
"Account_Broker_Agent", "Agent", 
"Account_Brokerage_Agency", "Agent", 
"Account_Carrier", "Carrier", 
"Account_Groups_of_1", "Individual",
"Account_Individual_Family", "Individual",
"AccountSupport", "Support",

"Account_Large_Group", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", ""))),
"AccountSmallGroup", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", ""))),
"General")

If it helps please like and mark as correct, it may help others.

Good luck.
This was selected as the best answer
Tom STom S
Thanks that was what I needed to make it work!
Agustin BAgustin B
Hi Tom, please like and mark as best answer, so this question can be solved and others with the same question can get the solution faster.
Tom STom S
I did mark it as answered yesterday but I must have not done something correctly.  I'll do it again.  Thanks for your help!