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
Rama_SFDCRama_SFDC 

How to control the record type selection from Quick action in lightning

Hi All ,
I'm creating a record from quick action button (lightning component ) where my target object has  4 record type , when i'm calling the target object it is returning all the record types (using custom lightning component for selecting record type) irrestpective of permission set , but all the record types are controlled by the permisson set .who have the permission set those records types should be display .How can we achive this requirment ?
Best Answer chosen by Rama_SFDC
Raj VakatiRaj Vakati
Yes . While Displying it self check the record type permission by using isAvailable() method 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_RecordTypeInfo.htm
 
public static Map<Id, String> fetchRecordTypeValues(String objectName){

        List<Schema.RecordTypeInfo> recordtypes = Schema.getGlobalDescribe().get(objectName).getDescribe().getRecordTypeInfos();    

        recordtypemap = new Map<Id, String>();

        for(RecordTypeInfo rt : recordtypes){

            if(rt.getName() != 'Master' && rt.getName().trim() != '' & rt.isAvailable())

            recordtypemap.put(rt.getRecordTypeId(), rt.getName());

        }        

        return recordtypemap;

    }

 

All Answers

Raj VakatiRaj Vakati
Refer this link 

http://sfdcfacts.com/apex/record-type-selector-quick-action-in-lightning/
Rama_SFDCRama_SFDC
@Raj V  Thanks friend for sharing the link ,
As per above link it will show all the record types irrespective of record type permissions and  when try to save record then only showing error message .
is it any option to hide record type selection in initial page ?.
 
Raj VakatiRaj Vakati
Yes . While Displying it self check the record type permission by using isAvailable() method 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_RecordTypeInfo.htm
 
public static Map<Id, String> fetchRecordTypeValues(String objectName){

        List<Schema.RecordTypeInfo> recordtypes = Schema.getGlobalDescribe().get(objectName).getDescribe().getRecordTypeInfos();    

        recordtypemap = new Map<Id, String>();

        for(RecordTypeInfo rt : recordtypes){

            if(rt.getName() != 'Master' && rt.getName().trim() != '' & rt.isAvailable())

            recordtypemap.put(rt.getRecordTypeId(), rt.getName());

        }        

        return recordtypemap;

    }

 
This was selected as the best answer
Rama_SFDCRama_SFDC
Thanks  @Raj V .
This is what i'm expecting . Perfect fix .  :)

Cheers !!