You need to sign in to do that
Don't have an account?

Can someone help me with the below apex code ? I am new to this and would appreciate your help.
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 :

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: <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 :
The 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.
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: <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 :
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.
Create a server-side controller as above and call it from a client-side controller.