Give Guest Users Access to Create Records

So guest users can create object records, configure the guest user profile to include create access for the desired object.

To grant create access to an object, you must grant read access to the object. If read access isn’t needed on that object, we recommend removing all permissions for that object and running the create logic in a without sharing controller.

Perform data validation on guest-created data to ensure that it doesn’t impact your automated processes.

Tip

Record IDs and Guest Users 

After record creation, don’t include the record ID in the response to the client. To create a unique record identifier for later access, encrypt the record ID with the record creation timestamp, and return the encrypted string to the client.

When you retrieve a record, the record ID is automatically included in the object. Remove the record ID from the object, and don’t pass it to the client.

Record Creation and Access in Apex Methods 

Guest user sharing rules take effect after the transaction completes. If Apex code with sharing creates and then requests the newly created record, and the guest user is relying on sharing rules to access the record, the read request fails because the guest sharing rules haven’t taken effect. To allow a guest user to create a record and read the newly created record in the same method, define the class with the without sharing keyword.

Record Creation and Access in Flow 

In a flow, the Create Records element doesn’t create records until the interview executes a Screen, Local Action, or Pause element. To create and read the same record in the same flow, insert a screen between record creation and retrieval, or read the record in an Apex action.

Samples 

See Also