function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
edoardo_spanoedoardo_spano 

Error in formula field with multiselect picklist

Hi all,

I'm trying to write the below formula in a boolean formula field:
INCLUDES($User.Roles__c,Involved_Role__c)

Roles__c is a multiselect picklist. Involved_Role__c is a text field.

When I try to save the system throw this exception:
Error: Incorrect parameter type for function 'INCLUDES()'. Expected Text Literal, received Text

I tried to use the TEXT function on Involved_Role__c field, but it doesn't work.

How can I troubleshoot this issue?

Thanks in advance.
Edoardo
Code+1Code+1
Hi edoardo_spano,

 Please let me know the requirement... What are you trying to achieve ?

Thanks..
Amit Chaudhary 8Amit Chaudhary 8
Please try below

INCLUDES(Involved_Role__c,$User.Roles__c)


 
NaveenReddyNaveenReddy
Hi,
 INCLUDES allows second parameter must be text literal i.e. give some text value not text field.
ex:
INCLUDES($User.Roles__c,'some string')

Thanks,
naveen

 
edoardo_spanoedoardo_spano
Hi Krishna,

I need to create a report which should show all records that have the involved role included in all selected roles of the logged user.
I thought to create a boolean formula field that is set to true when my requirement is verified, because I have no other ideas.

Can you help me with my trouble?

Thanks in advance
Edoardo
Faisal BahadurFaisal Bahadur

hi , just add Text() with picklist filed 

INCLUDES(Text($User.Roles__c),Involved_Role__c)

try this.
 

edoardo_spanoedoardo_spano
Hi Faisal,
Roles__c is a multi-select picklist, so I can't use TEXT function.
NaveenReddyNaveenReddy
Hi,
 You can write a trigger on that Object.

1)Compare both the fields 
2)If Involved_Role__c matches Roles__c update a boolean  field to true.
3)Then you can genearate reports for the records which are true.


Sample code for this is 
Trigger MyTrigger on CustomObject__c(before insert)
{
for(CustomObject__c c:Trigger.New)
{
     String s=c.Roles__c;
     if(s.contains(Involved_Role__c))
         Boolean1=true;
        
  }
}



Thanks,
naveen.
ManojjenaManojjena
Hi edoardo_spano ,

Try with below formula ,
 
IF(Involved_Role__c=='A' && INCLUDES( $User.Roles__c ,"A"),true,
IF(Involved_Role__c=='B' && INCLUDES( $User.Roles__c ,"B"),true,
IF(Involved_Role__c=='C' && INCLUDES( $User.Roles__c ,"C"),true,
IF(Involved_Role__c=='D' && INCLUDES( $User.Roles__c ,"D"),True,False))))
Replace A-D with your multipicklist value . 
Let me know if it helps .

 
Code+1Code+1
Hi edoardo_spano,
 
 Roles__c (Multi Select Picklist field)

 Values are below --
 Junior Developer
 Developer
 Senior Developer
 Lead
 Manager
 Senior Manager

 Involved_Role__c (TEXT field) 

 Decision is a formula field with the criteria --

 IF(Involved_Role__c=='Junior Developer' && INCLUDES(Roles__c ,"Junior Developer"),"Junior Developer",
 IF(Involved_Role__c=='Developer' && INCLUDES(Roles__c ,"Developer"),"Developer",
 IF(Involved_Role__c=='Senior Developer' && INCLUDES(Roles__c ,"Senior Developer"),"Senior Developer",
 IF(Involved_Role__c=='Lead' && INCLUDES(Roles__c ,"Lead"),"Lead",
 IF(Involved_Role__c=='Manager' && INCLUDES(Roles__c ,"Lead"),"Manager",
 IF(Involved_Role__c=='Senior Manager' && INCLUDES(Roles__c ,"Senior Manager"),"Senior Manager",
 Null))))))
 
Please key in only one value for the Involved_Role__c field...
Else, include that criteria also in the formula field, it will work ..

Thanks..