How to retrieve the Record Type which are accessible by user's Profile only?

Sample Code:

         List < SelectOption > listRecTypes = new List < SelectOption >();
        for ( RecordTypeInfo info: Opportunity.SObjectType.getDescribe().getRecordTypeInfos() ) {
            if(info.isAvailable()) {
                listRecTypes.add(new SelectOption(info.getRecordTypeId(), info.getName()));
            }
        }

The above code will add only the record type accessible to the user.

Cheers!!!

No comments:

Post a Comment