• Shruti Ranjana 13
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
We have a custom object "Sample Request", when creating a record for the object "Sample Request", the option to select record type is displayed if the user has "Sample_Request_Select_Record_Type" permission set assigned to their profile : 
User-added image
This is working fine in SF classic as the following apex code is written :

  public Boolean getSelectRecordType(){
        list<PermissionSetAssignment> permissionSetAssignments = [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'Sample_Request_Select_Record_Type'];

        return (permissionSetAssignments.size() != 0);
    }

This code is called in the VF page :

<apex:outputPanel rendered="{!selectRecordType}"> Select a record type to use: &nbsp; <apex:selectList id="recordTypeId" value="{!recordTypeId}" size="1"> <apex:selectOptions value="{!rectypes}" /> </apex:selectList>

But when the same scenario is run in SF lightning, the users are not getting an option to select the record type :
User-added imageThe display record type section is missing because the lightning coding does not have the logic on the basis of "permission set" assignment. Can someone please help me with writing the lightning(@AuraEnabled) code for just this section of apex code :

public Boolean getSelectRecordType(){
        list<PermissionSetAssignment> permissionSetAssignments = [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'Sample_Request_Select_Record_Type'];

        return (permissionSetAssignments.size() != 0);
    }

Really appreciate the help!! Thanks in advance.