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
khillan bhardwajkhillan bhardwaj 

Count the all available picklist value in the multiselect picklist of an Object

Dear Sir ,

            i want to calculate no. of the picklist values avaiable in the multiselect picklist of the Object and i want to show that counted value in the vf page

 

thanks u

Best Answer chosen by Admin (Salesforce Developers) 
ForcepowerForcepower

Khillan,

 

Something like this:

 

       Schema.DescribeFieldResult fieldResult;

        fieldResult    = My_Object__c.My_field1__c.getDescribe();

       List<Schema.PicklistEntry> picklistVals= fieldResult.getPicklistValues();

       Integer listSize = picklistVals.size();

 

Best,

Ram

All Answers

ForcepowerForcepower

Khillan,

 

Something like this:

 

       Schema.DescribeFieldResult fieldResult;

        fieldResult    = My_Object__c.My_field1__c.getDescribe();

       List<Schema.PicklistEntry> picklistVals= fieldResult.getPicklistValues();

       Integer listSize = picklistVals.size();

 

Best,

Ram

This was selected as the best answer
souvik9086souvik9086

Hi,

 

Try this

 

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
public SObjectType sot = gd.get(selectedObject);

DescribeFieldResult dfr = sot.getDescribe().fields.getMap().get(pklstName).getDescribe();
List<PicklistEntry> entries = dfr.getPicklistValues();

Integer sizeOfPkValues = entries.size();

 

You can use this "sizeOfPkValues" in vf page.

 

If this post solves your problem kindly mark it as solution. if this post is helpful please throw Kudos.

Thanks

 

khillan bhardwajkhillan bhardwaj

yes sir this is work for get my objective