0

We have a salesforce lightning community. When guest users agree to register in one of the community pages(clicking a checkbox), the underlying code creates an account, a community user, public group, apex share and add the user to the public group as a group member. The code updates the account record with the related public group id and finally sends out an verification email to the user. All of these actions occur as a guest user. With summer 20 changes to guest user profile, guest user profile cannot create group or group member and can only create/read (not edit) objects. Hence our code has started failing in sandbox at the point of group creation with the following error.

Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION

Any ideas how to fix it.

2 Answers 2

0

This is due to the guest user being unable to see the Account/Contact. As such, references that use those ids will fail.

To resolve this, you'll have to create a Sharing Setting that gives the guest user read-only access to Accounts. Steps: Setup > Sharing Settings > Account > New.

Criteria should be something that includes all accounts, such as "Name is not Blank". "Share with" should show the guest user. Access should start with Read-Only.

Definitely test in the sandbox first. Hope this helps!

4
  • thanks for your reply. But the code started failing only after summer 20 was applied. I can see the in the debug log, public group insert fails. Commented Jun 11, 2020 at 17:17
  • I get this error on public group insert Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, An unknown excep Commented Jun 11, 2020 at 17:24
  • Yes, this is caused by the summer 20 update. My sharing rule suggestion is the way to work around that. Basically, SF took away some access, but you can use the rule to get it back.
    – JimG
    Commented Jun 12, 2020 at 14:20
  • You can confirm the access is the problem by unchecking the "secure guest access" setting on the sharing screen. If it starts working again, it's the new setting. Then re-enable the new setting and try with the my suggested sharing rule.
    – JimG
    Commented Jun 12, 2020 at 14:21
0

Salesforce guest users can't create public groups anymore. We had to redesign some of our functionality to get around this.

You must log in to answer this question.

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