3

I have a Multi-select picklist in account object and I want to display the selected picklist values in contact object using a formula field. I came across many using multiple If conditions. In my scenario, I have 20+ values in Multi-select picklist, how am I supposed to do that

1
  • 1
    Use Case Function instead of Multiple If.. Commented Nov 10, 2017 at 9:42

3 Answers 3

5

To update a contact object formula field based on the values from the account object multi-select picklist . In contact formula field write down as

IF(INCLUDES(Account.Multi_select__c,"value"),"value;",null)& IF(INCLUDES(Account.Multi_select__c,"value"),value;",null)& IF(INCLUDES(Account.Multi_select__c,"value"),"value;",null)& IF(INCLUDES(Account.Multi_select__c,"value"),"value;",null) 

and goes on. When my formula field has more characters this is the error I faced

The formula expression is invalid: Formula is too long (6,647 characters). Maximum length is 3,900 characters

In that case, try to use trigger its a good choice.

trigger accountTrigger on Account(after insert,after update) { List<contact>contactlst = new List<contact>(); List<contact> cnt = new List<contact>(); map<string,string> mapOfAccntIds = new map<string,string>(); for(Account act:Trigger.new){ mapOfAccntIds.put(act.id, act.Multi_select__c); } contactlst = [select id, Multi_Select_Text__c, name, AccountId from contact where AccountId IN: mapOfAccntIds.keySet()]; for(contact c :contactlst ){ c.Multi_Select_Text__c= mapOfAccntIds.get(c.accountId); cnt.add(c); } if(cnt != null & cnt.Size()> 0) upsert cnt; } 
3

you could try something like this:

> IF(INCLUDES( Multi_Picklist_1__c , "A"), "A" + BR(), NULL) + > IF(INCLUDES( Multi_Picklist_1__c , "B"), "B" + BR(), NULL) + > IF(INCLUDES( Multi_Picklist_1__c , "C"), "C", NULL) 
0
2

As stated in the doc...

Multi-select picklist fields can only be used in these functions:
- INCLUDES
- ISBLANK
- ISNULL

So... if you want to stick to a formula... you are stuck with the IF-INCLUDES for each option.

You could alternative consider making a very simple trigger on before insert and before update on your parent object that writes the String with all the values into a String field, and put a formula linked to it on the child object.

1
  • 1
    took your advice and wrote trigger :) Commented Nov 13, 2017 at 11:09

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.