Hi I have faced the same problem so this is what i did
check for the lookup field permission on the child object (It needs to be atleast read)
in classic we are able to see the related list irrespective of the fact if child object lookup field has access or not but in lightning only those related list will show up whose child object lookup field has atleast read access
What you want are lightning mass actions, which aren't available and currently slated for "future" release on the roadmap. You can achieve the same result by developing a basic Visualforce page with an extension class, configure a list button, and add the button to the object's list views Search Layout setting. For the "accept" scenario, you would first write an apex class like:
public class CaseAcceptOwnershipExtension {
PageReference cancel;
Case[] cases;
public CaseAcceptOwnershipExtension(ApexPages.StandardSetController ctrl) {
cases = (Case[])ctrl.getSelected();
cancel = ctrl.cancel();
}
public PageReference updateCases() {
for(Case c : cases) {
c.OwnerId = UserInfo.getUserId();
}
update cases;
return cancel.setRedirect(true);
}
}
Then you'd write an empty Visualforce page that calls the apex class to execute the logic:
<apex:page standardController="Case" recordSetVar="cases"
extensions="CaseAcceptOwnershipExtension" action="{!updateCases}"></apex:page>
Once you have finished coding, go to Setup | Customize | Cases | Buttons, Links, and Actions and click New Button or Link. Configure a List Button with checkboxes enabled, Content Source set to Visualforce, and select the Visualforce page you created for the Content. Click Save. Then go to Setup | Customize | Cases | Search Layouts and edit Cases List View to include your new button.
You will now see the button available for Case list views in Lightning Experience.
Please keep in mind that the above code will execute irrespective of user permissions and security. To include security checks like record accessibility and user permissions, use the below class:
public with sharing class CaseAcceptOwnershipExtension {
PageReference cancel;
Case[] cases;
public CaseAcceptOwnershipExtension(ApexPages.StandardSetController ctrl) {
// Return the list of sObjects that have been selected
cases = (Case[])ctrl.getSelected();
cancel = ctrl.cancel();
}
public PageReference updateCases() {
// Check if running user has "Transfer Record" permission
List<PermissionSetAssignment> psa = [SELECT Id, AssigneeId, PermissionSet.IsOwnedByProfile
FROM PermissionSetAssignment
WHERE (PermissionSet.PermissionsTransferAnyEntity = true OR
PermissionSet.PermissionsTransferAnyCase = true)
AND Assignee.IsActive = true AND AssigneeId =: UserInfo.getUserId()];
// Create a map of Ids for the selected records
Map<Id,Case> casesSelected = new Map<Id,Case>([SELECT Id FROM Case WHERE Id =: cases]);
System.debug('=== all keys in the map: ' + casesSelected.keySet());
System.debug('=== all values in the map (as a List): ' + casesSelected.values());
// Any queue members or users higher in a role hierarchy can take ownership of records in a queue
Map<Id,UserRecordAccess> ura = new Map<Id,UserRecordAccess>();
for(UserRecordAccess a : [SELECT RecordId
FROM UserRecordAccess
WHERE UserId =: UserInfo.getUserId()
AND RecordId IN: casesSelected.keySet() AND HasTransferAccess = true]) {
ura.put(a.RecordId, a);
}
System.debug('=== all keys in the map: ' + ura.keySet());
System.debug('=== all values in the map (as a List): ' + ura.values());
// If user has "Transfer Record/Case" permission OR HasTransferAccess = true, then update OwnerId
for(Case c : cases) {
if(psa.size()>0 || ura.containsKey(c.Id)) {
// Assign OwnerId to running user's userId
c.OwnerId = UserInfo.getUserId();
c.Status = 'Accepted';
}
}
// DML operation outside of for loop
update cases;
// Navigate back to list view and not display the visualforce page
return cancel.setRedirect(true);
}
}
Best Answer
Even I faced this issue. Requirement : Redirect the page on new account depending on the record type.
Conclusion: Its working fine in SF Classic but in Lightning i'm getting the same error. The records are not capturing the selected record type. I tried sending the record type id in the url, but i guess the url hacking in disable in lightning.
Workaround : Might need to create a custom vf page of the information that need to be captured & insert in the record depending on the record type.
Hope this information might help you.