1

I have standard Account object on my standard page layout. And I have 2 dependent picklists, when both picklists are selected, I want to set data to 3rd pick list (Cannot add dependent pick list because data volume) depend on 1st and 2nd picklists. I have custom object with mapping dependency of 3 pick lists.

(Custom Object: 1st Pick list value 1, 2nd Pick list value 1 --> 3rd Pick list value;

1st Pick list value 1, 2nd Pick list value 2 --> 3rd Pick list value; etc.)

How can I solve this situation using my custom object and 3 picklists?

0

Rather than using Custom Object you can leverage Custom Metadata types.

In the standard page layout, you cannot directly assign third picklist value.

It is could be better you can handle this through trigger (before insert or before update).

I could be also suggest you to leverage Platform Cache where you can cache the mapping and retrieve the third picklist value based on 1st and 2nd.

Logic is:

During first time assignment, check value is exist in the Cache and if not exists, then prepare values in the Cache. And next time onwards read of the Cache.

Note: You cannot put special character or space as a key in Cache.

This code might help you.

public static String getThirdPicklistValue(String firstPicklist,String SecondPicklist)
{

    String thirdPicklist = (String)Cache.Org.get(firstPicklist.replaceSpecialChars() + SecondPicklist.replaceSpecialChars());

    if(thirdPicklist ==null)
    {
        for(Case_Type_Mapping__mdt mdt: [SELECT FirstPicklist__c,SecondPicklist__c,
                                                ThirdPicklist__c
                                        FROM Picklist_Mapping__mdt])
        {

            if(mdt.FirstPicklist__c !=null && mdt.SecondPicklist__c != null && mdt.ThirdPicklist__c != null)
            {               
                Cache.Org.put(mdt.FirstPicklist__c.replaceSpecialChars() + mdt.SecondPicklist__c.replaceSpecialChars(), mdt.ThirdPicklist__c); 
            } 
        } 
    }       
    return thirdPicklist = (String)Cache.Org.get(firstPicklist.replaceSpecialChars() + SecondPicklist.replaceSpecialChars())        

}

public static String replaceSpecialChars(String str)
{
    return str.replace(' ','').replace('(','').replace(')','').replace('-','').replace('/','').replace('+','').replace('_','');
}

For more information, refer Platform Cache Docs and Platform Cache Basics Trailhead

  • Thanks for your assistance. But I need to load data to 3rd picklist before crud operation happens. Like ajax call, I want to load 3rd picklist depend on other 2 picklists. – Tharaka De Silva Mar 20 '17 at 8:44
  • Then, you need to build VFP, to implement that functionality. Standard page layout does not provide this functionality. – Santanu Boral Mar 20 '17 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.