1

If I want a picklist with the Stagename and the Probability, I can use the code below.

But how can I get a list of RecordTypes with the Stagenames?

public List <SelectOption> getProductList() {
    List<SelectOption> options =  new List<SelectOption>();    
    options.add(new selectOption('None','--- None ---'));    
    Schema.DescribeFieldResult fieldResult = Opportunity.RecordTypeId.getDescribe();    
    List<Schema.picklistEntry> vls = fieldResult.getPicklistValues();    
    for(Schema.picklistEntry v:vls)    
    {    
        options.add(new selectOption(v.getLabel(),v.getValue()));                    
    }
    RETURN options;    
}
2
  • Your question is quite vague. You've posted the code for a picklist, and then asked for a list. Which are you trying to create? If you want a list of record types with stage names, how should the list look? What code have you written so far?
    – Rob
    Aug 24 '15 at 13:47
  • I wrote the code above. I thought that I can take the Opportunity.RecordTypeId but it doesn't work. I mean also a picklist. For the StageName with the probability it works fine, but how is the process for the recordtype to the stagename / sales process.
    – peXeq
    Aug 24 '15 at 18:46
1

The RecordTypeId field is a lookup, not a picklist.

List<SelectOption> options = new List<SelectOption>();
for (RecordType recordType : [
    SELECT Name FROM RecordType WHERE SObjectType = 'Opportunity'
]) options.add(new SelectOption(recordType.Id, recordType.Name));

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.