function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew McNamara 13Andrew McNamara 13 

lightning:recordeditform guest user case and accountid

I want to use lightning:recordeditform in a component in lightning communities to create a case. I need the guest user to be able to either create a person account or match a existing account to retrieve the accountid and the personcontactid. When I insert the accountid into the case and call the submit() method for the recordeditform I'm getting a "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITIY"....which makes sense as the guest user doesn't have access. 
I have privacy issues setting the account owner to the guest user as that would make all guest users have permissions to all accounts. 

How can I use lightning:recordeditform to create a case as a guest user in the community? 

 
Meghna Vijay 7Meghna Vijay 7
Hi Andrew,

You are getting this error because you don't have read access on that account. How about creating an AccountShare record and share it with the guest user with Read Access and then use it to create a case . For more information follow this link:-
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_accountshare.htm

Hope it helps, if it does mark it as solved.
Thanks

 
Andrew McNamara 13Andrew McNamara 13
I was looking into using AccountShare or Apex sharing, but the issue is that I will have to remove the AccountShare record in the onSuccess action as the guest user cannot have access to multiple accounts for privacy issues.
So essentially, onSubmit and onSuccess will be a server call to add and remove the share. 
I am using the recordeditform to prevent multiple apex server transactions, and this process just seems costly.