+ Start a Discussion
Aidel BruckAidel Bruck 

Schema.SObjectType.Opportunity.getRecordTypeInfosByName not returning the full list

I am trying to get the list of all the opportunity record types by using the following code

 Map<String,Schema.RecordTypeInfo> opprecordTypeMapByName= new Map<String,Schema.RecordTypeInfo>();
opprecordTypeMapByName = Schema.SObjectType.Opportunity.getRecordTypeInfosByName();
But the opprecordtypemapbyname only contains a few record types and not everything. 
Any ideas why?
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Aidel,

Greetings to you!

Make sure that you have access to all the record types in Opportunity object. Also, make sure that the new record type has an assigned page layout.

1. Go to Profile.
2. Click on the profile to which you are assigned.
3. Scroll down to the "Record Types" section.
4. Make sure that the record type is listed as one that you currently have access to. If not, click edit next to the object and add it.

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