I have a situation that seems to be consistent with the top comments here: https://success.salesforce.com/ideaview?id=087300000006n4GAAQ
Specifically, i have a Content Workspace aka Content Library, and a user added to it as a Collaborator (directly, not via group) with Read
access.
If the user opens a record (e.g. Account
) and tries to use Add Files
button in LEX and selects that file in the Library, sharing fails with the error:
Can't add 1 file to Account.
I can see in Chrome that Aura action from the API said:
{
"id": "9304;a",
"state": "SUCCESS",
"returnValue": {
"SomeId": {
"docId": "DocId here",
"recordId": "record Id Here",
"shareSuccess": false,
"shareExists": false,
"canUserEditFile": false
}
},
"error": []
}
So LEX can somehow determine that the user canUserEditFile
.
How can i do the same in Apex?
My goal is to automatically create ContentDocumentLink
records via a trigger, and so I need to determine whether that is possible.
When I run the following query:
SELECT RecordId,MaxAccessLevel FROM UserRecordAccess WHERE UserId = 'User' AND RecordId = 'record'
I get the access level as All
for the same file that is throwing that error