You need to sign in to do that
Don't have an account?
kavya mareedu
Hello People!
While writing a SOQL Query if we have to group by a picklist value, how should I define it.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Greetings to you!
You can do it like this:
Please refer to the below link for more information:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_groupby.htm
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
You have two option to do this.
1- You can go with the Query-
SELECT StageName label ,StageName value
FROM Opportunity
GROUP BY StageName
2- You can go with schema class-
Try the bellow Code and put your Custom object according to your need.
public class MyOwnTestController {
public static List<String> getPickListValuesIntoList(){
List<String> pickListValuesList= new List<String>();
Schema.DescribeFieldResult fieldResult = Opportunity.StageName.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple){
pickListValuesList.add(pickListVal.getLabel());
}
System.debug('hello'+pickListValuesList);
return pickListValuesList;
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi