+ Start a Discussion
Raja JammulaRaja Jammula 

Formula Field for Multi select picklist

Hi, i have a scenario where i have a button where i am doing URL hacking and populating the values from one object to another object on click of  a button.

The problem here is the button is called from two places. There is a field 'Product_Type__c ' which is a single picklist field and populates the value to the field-'product' on the destination. but on second place where we are calling the button the field is multi-select picklist field - 'Product_Categories__c ' and the destination field is same field - 'product'. when i am calling this it won't take the value from both the places.

so i thought of creating a formula field to populate the values and then use this formula field in URL hack of the button. but i am getting an error when trying to do it. the formula i am using:

IF( ISPICKVAL(Type, 'Multi-Product')  , TEXT(Product_Categories__c ) ,  Product_Type__c )

as multiselect can't use text 

 can anyone help me
Best Answer chosen by Raja Jammula
Raja JammulaRaja Jammula
Thanks Harshil,

this formula finally works:

IF( ISPICKVAL(Type, 'Multi-Product') , IF(ISBLANK( Multi_Picklist_1__c ), NULL, SUBSTITUTE( IF(INCLUDES(Multi_Picklist_1__c, "Multi"), "Multi, ", NULL) + IF(INCLUDES(Multi_Picklist_1__c, "Picklist"), "Picklist, ", NULL) + IF(INCLUDES(Multi_Picklist_1__c, "Fields"), "Fields, ", NULL) + IF(INCLUDES(Multi_Picklist_1__c, "Suck"), "Suck, ", NULL) + ".", ", .", NULL)) , TEXT(Product_Type__c ))

All Answers

HARSHIL PARIKH AKA:GovindHARSHIL PARIKH AKA:Govind
I would suggest making a use of   INCLUDES(multiselect_picklist_field, text_literal)  function in salesforce.

This is what it does:
 INCLUDES(multiselect_picklist_field, text_literal) 
Determines if any value selected in a multi-select picklist field equals a text literal you specify.

Something along this lines:
 INCLUDES(Product_Categories__c, "NAME OF YOUR VALUE") 
Hope it helps!

 
Raja JammulaRaja Jammula
Hi nitish,
i tried it but i am getting error on that too. can you give me example.

i don't know whether it is correct here what i tried:

IF( ISPICKVAL(Type, 'Multi-Product')  , INCLUDES(CSG_Product_Categories__c , "DC") ,Product_Type__c )

Error: Field Product_Type__c is a picklist field. Picklist fields are only supported in certain functions
HARSHIL PARIKH AKA:GovindHARSHIL PARIKH AKA:Govind
OR you can have formula something like...

Formula_Field__c =
IF(INCLUDES(Product_Categories__c, "NAME OF YOUR VALUE"), "NAME OF YOUR VALUE", NULL)

then use this field (Formula__Field__c) output value in pre-populating the value on click of a button.
Raja JammulaRaja Jammula
i have tried that:

IF( ISPICKVAL(Type, 'Multi-Product')  , INCLUDES(CSG_Product_Categories__c , "DC") , "DC" + BR(),Product_Type__c )

getting the error
Error: Field Product_Type__c is a picklist field. Picklist fields are only supported in certain functions

 
HARSHIL PARIKH AKA:GovindHARSHIL PARIKH AKA:Govind
IF( 

OR(
   ISPICKVAL(Type, "Multi-Product"), 
   INCLUDES(CSG_Product_Categories__c , "DC") 
  ),
  "DC" + BR(),TEXT(Product_Type__c) )
Put OR or AND based on your need
 
Raja JammulaRaja Jammula
Thanks Harshil,

this formula finally works:

IF( ISPICKVAL(Type, 'Multi-Product') , IF(ISBLANK( Multi_Picklist_1__c ), NULL, SUBSTITUTE( IF(INCLUDES(Multi_Picklist_1__c, "Multi"), "Multi, ", NULL) + IF(INCLUDES(Multi_Picklist_1__c, "Picklist"), "Picklist, ", NULL) + IF(INCLUDES(Multi_Picklist_1__c, "Fields"), "Fields, ", NULL) + IF(INCLUDES(Multi_Picklist_1__c, "Suck"), "Suck, ", NULL) + ".", ", .", NULL)) , TEXT(Product_Type__c ))
This was selected as the best answer