0

Currently, we have a field update workflow on a field called Combo Location. The purpose of this field is to pull multiple cities when there are combination events that occur in up to 2 cities. We now have combo events that can go up to 4 cities.

I am trying to update the code so that this Combo Location field can detect if there are 3 or 4 cities and then effectively update the field to "Location1/Location2/Location3/Location4" respectively.

The current code is as follows:

IF(Combo_Event_1__r.Venue__r.City__c = Combo_Event_2__r.Venue__r.City__c, Combo_Event_2__r.Venue__r.City__c, 


(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c))

I tried to implement the following code, but for some reason I'm not getting the desired result:

    IF((NOT(ISBLANK(Combo_Event_2__r.Venue__r.City__c))),
(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c)
    ,
IF((NOT(ISBLANK(Combo_Event_3__r.Venue__r.City__c))),
(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c)
    ,
IF((NOT(ISBLANK(Combo_Event_4__r.Venue__r.City__c))),
(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c & "/" & Combo_Event_4__r.Venue__r.City__c)
,
""
)))

Update 1:

I updated the code according to the suggestion, but I get a syntax error: "Error: Syntax error. Missing ')'"

IF(Combo_Event_4__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c & "/" & Combo_Event_4__r.Venue__r.City__c)
IF(Combo_Event_3__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c)
IF(Combo_Event_2__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c)
  ,"")))

1 Answer 1

1

Your if statements are backwards. You need to start from the most specific criteria and work your way to the most general:

if(city4 != null,...
if(city3 != null,...
if(city2 != null,...
  ...)))
3
  • Thank you for the response, I updated the code, but am getting a syntax error. Please note "Update 1" in the post. Jul 31, 2017 at 16:14
  • @Skobiwankanobi you're missing commas in your code: IF(Combo_Event_4__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c & "/" & Combo_Event_4__r.Venue__r.City__c), IF(Combo_Event_3__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c), IF(Combo_Event_2__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c), ,"")))
    – sfdcfox
    Jul 31, 2017 at 17:11
  • removed a redundant comman and the code is working correctly now! Thanks for the help: IF(Combo_Event_4__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c & "/" & Combo_Event_4__r.Venue__r.City__c), IF(Combo_Event_3__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c & "/" & Combo_Event_3__r.Venue__r.City__c), IF(Combo_Event_2__r.Venue__r.City__c != null,(Combo_Event_1__r.Venue__r.City__c & "/" & Combo_Event_2__r.Venue__r.City__c), ""))) Jul 31, 2017 at 18:18

You must log in to answer this question.

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