0

I am trying to let a guest user from our Salesforce site create a ContentDelivery record in order to create a public available link for a signature he just posted in the website. I cannot give him the permission to create ContentDelivery records; I tried by creating a custom permission set but the guest license doesn't let me assign it to him. Then I tried with an Apex class without sharing, but I still get this error message :

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ContentDocumentLinkTrigger: 
execution of AfterInsert\n\ncaused by: System.DmlException: Insert 
failed. First exception on row 0; first error: 
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access 
rights on cross-reference id:

Do you guys have any idea how to bypass this? I either need to somehow create the ContentDelivery record from another user as soon as it is needed, or give this permission to the guest user.

1 Answer 1

1

From my own experience and trials, there now is no ways to allow guest users to have the permission to do this.

The workaround I made is calling our-self with a technical admin user on the standard create record api to make the creation. Think of it as an right elevation during the process to make it working. To use with caution as the rights of the user will be admin (see all / modify all data). There are several situations where we ended up using this and report it works great.

I hope this suits your needs.

Some more implementation details :

  • Create a technical user with admin rights
  • Create an auth provider
  • Create a connected app (from app manager)
    • Callback url: take the value from connected app (after first save)
  • Create a named credential
    • Identity Type: Named principal
    • Use the auth provider
    • Run the authentication flow and connect using the technical user you used before

Now you can make api calls to your own org with other permissions.

Edit 01/dec/2022

Here are some links:

6
  • That's a very nice workaround, will take some time to implement so I will probably try it later. But thanks for your answer and very smart idea!
    – Brian23Gt
    Commented Feb 22, 2022 at 13:16
  • @Brian23Gt I have the exact same requirement. Can you share the code for the api call?
    – JK123
    Commented Nov 30, 2022 at 13:43
  • We make API calls to Salesforce standard API in our case, so full documentation for this is provided by Salesforce. You can also create your own WS to call (also documented). And making an API call is also documented. What would you need ? Commented Nov 30, 2022 at 18:47
  • According to my requirement on lwc button click guest user should be able to create content distribution. Also, can you please share the document link.
    – JK123
    Commented Dec 1, 2022 at 5:27
  • I added some documentations. If you have any questions during the process, you can post a new question and people will try to answer it. Commented Dec 1, 2022 at 9:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .