salesforcecustom-field-type

salesforce custom field use case


In Salesforce I am wanting create a custom field in Contact called 'Chapter' that references 2 other fields (State and Country' to auto populate itself. similar to a case in SQL

e.g.

‘Chapter' = 
    CASE
       When country = 'Aus' and state in ('NSW', 'ACT') then 'NSW / ACT` 
       When country = 'Aus' and state in ('VIC', 'TAS') then 'VIC / TAS`
       When country = 'Aus' and state in ('SA', 'NT') then 'SA / NT`
       When country = 'Aus' and state in ('WA, 'QLD') then 'WA/QLD'
       When country = 'NZ' then 'NZ'
       When country not in ('Aus', NZ) then 'INT'
    END

I presume I use the formula data type when creating field however I can not seem to write the formula.


Solution

  • I worked this out on my own. It was an custom field using a IF formula

    F(Country = "Aus" && State = "NSW" , "NSW/ACT", 
    IF(Country = "Aus" && State = "ACT" , "NSW/ACT", 
    IF(Country = "Aus" && State = "TAS" , "VIC/TAS", 
    IF(Country = "Aus" && State = "VIC" , "VIC/TAS", 
    IF(Country = "Aus" && State = "SA" , "SA/NT", 
    IF(Country = "Aus" && State = "NT" , "SA/NT", 
    IF(Country = "Aus" && State = "WA" , "WA", 
    IF(Country = "Aus" && State = "QLD" , "QLD", 
    IF(Country = "NZ" , "NZ", 
    IF(Country <> "New Zealand" && Country <> "Aus" , "INT", 
    ""))))))))))