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
ksandipam1.3911488281559465E12ksandipam1.3911488281559465E12 

Selected record types of Specific profile on Specific Object

I have logged in as System Admin profile, In apex I wrote the code to
retrieve the selected record types of Account object. For example, in
account object I have 10 record types and I have selected only 5 record
types to one profile( X Profile). From the apex code, I want to retrieve
selected record types of Account object for specific profile( X Profile)

This is the code for current user profile record types. Now I want to get
the record types of specific profile. When I pass the profile Id, I want to
get the account object record types of that profile


public without sharing class SelectedRecordTypes {
public static List GetAvailableRecordTypeNamesForSObject( Schema
.SObjectType ObjType, Id profileId ) {
try {
User userId = [Select Id from User where Profile.Id =:profileId];
List names = new List();
List RecordTypes= new List();
List recTypeIds = new List ();
List infos = objType.getDescribe().getRecordTypeInfos();

// If there are 2 or more RecordTypes...
if (infos.size() > 1) {
for (RecordTypeInfo i : infos) {
if (i.isAvailable()
// Ignore the Master Record Type, whose Id always ends with
'AAA'.
// We check the Id because Name can change depending on the
user's language.
&& !String.valueOf(i.getRecordTypeId()).endsWith('AAA'))
names.add(i.getName());
}
}
// Otherwise there's just the Master record type,
// so add it in, since it MUST always be available
else names.add(infos[0].getName());
RecordTypes = [select Id, name from RecordType where Name IN :names];
for (RecordType rec : recordTypes) {
recTypeIds.add(rec.Id);
}
return RecordTypes;
} catch ( Exception recTypeException ) {
system.debug(':::::::::: recTypeException:'+recTypeException);
return null;
}
}
}

Is there any way to retrieve Selected record types of Specific profile on Specific Object?
Ashish_SFDCAshish_SFDC
Hi , 


See the below threads with similar issue,

Finding if which users have a record type available to them using SOQL

http://salesforce.stackexchange.com/questions/5063/finding-if-which-users-have-a-record-type-available-to-them-using-soql

how to determine which profiles are assigned to a record type

http://stackoverflow.com/questions/11970460/how-to-determine-which-profiles-are-assigned-to-a-record-type


Regards,
Ashish
Tejas KshirsagarTejas Kshirsagar
Hello bro ,i need help same functionality i need to built
do u have the code for this case?
 
Ankitta SharmaAnkitta Sharma
New Ringtone Mp3 Free Download (https://tunemobi.in) Top Ringtones 2022 Download For Android And Iphone Ringtone.