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
Patrick WongPatrick Wong 

MasterLabel of OpportunityStage Translation

Is there any way to get the Translated MasterLabel of the OpportunityStage in Apex Code?
Best Answer chosen by Patrick Wong
Patrick WongPatrick Wong
The problem was solved with the following code.

for(PicklistEntry picklistEntry : Opportunity.StageName.getDescribe().getPicklistValues()){
          picklistEntry.getLabel();
}
 

All Answers

Gaurav KheterpalGaurav Kheterpal
Perhaps do something along these lines
 
List<OpportunityStage> lstOppStages = [Select SortOrder, MasterLabel, IsActive 
					       From   OpportunityStage 
	                                       Where  IsActive=true 
	                                       Order by SortOrder];
	public List<String> lstStages {
		get {
			List<String> lstStages = new List<String>();
			for (OpportunityStage stg : lstOppStages) {
				lstStages.add(stg.MasterLabel);
			} 
			return lstStages;	
		}
	}
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker


 
Patrick WongPatrick Wong
Hi Gaurav Kheterpal, 

Thanks for your reply. The MasterLabel in OpportunityStage Object is the un-translated value. I need the translation of all Opportunity Stage Value.
Patrick WongPatrick Wong
The problem was solved with the following code.

for(PicklistEntry picklistEntry : Opportunity.StageName.getDescribe().getPicklistValues()){
          picklistEntry.getLabel();
}
 
This was selected as the best answer