if(opp1.size()>0)
{
for(integer i=0;i<opp1.size();i++)
{
//oppid=String.valueOf(opp1[i].get('Id'));
stage=String.valueOf(opp1[i].get('StageName'));
tmp1+='<th>'+stage+'</th>';
counter++;
}
}
2 Answers
To retrieve the values of picklist you need to use Schema.DescribeFieldResult
.
here is sample code to retrieve values of StageName
picklist of Opportunity
object.
Schema.DescribeFieldResult fieldResult = Opportunity.StageName.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.PicklistEntry s:ple){
System.debug('value: '+s.getLabel());
}
See this thread for more information.
-
-
Description Resource Path Location Type Save error: Method does not exist or incorrect signature: Opportunity.StageName.getDescribe() opportunity.cls /basit/src/classes line 33 Force.com save problem Jun 28, 2016 at 10:09
-
This code works fine.I have tested it.Can you update your code what are you doing?– Mr.FrodoJun 28, 2016 at 10:14
-
public with sharing class opportunity{ public list<AggregateResult> opp{get;set;} public opportunity() { opp=[select StageName from Opportunity group by StageName ]; public String getOpportunity_Plan() { string stage=''; Schema.DescribeFieldResult fieldResult = Opportunity.StageName.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); for(Schema.PicklistEntry s:ple) { stage=s.getLabel(); } } } Jun 28, 2016 at 10:20
-
change name of your class from
Opportunity
to something else.It is conflicting.– Mr.FrodoJun 28, 2016 at 10:31
Just replace
stage=String.valueOf(opp1[i].get('StageName'));
by this :
stage=String.valueOf(opp1[i].StageName);
Regards,
Ajay
opp1
? is it a list?