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
oj2131oj2131 

Editing records upserted by guest users

Hey,

 

I am currently designing a donation payment system where guest users upsert their information into SalesForce records when they make a donation. My program is designed so that new info would automatically update overlapping older records.

 

For example, my program compares records based on email. If a user makes a donation with a given email, the program scans the records for all contacts with that email. If there is no match, then the new contact is inserted. However, if there is a match, then the new contact overwrites the older contact with the updated information.

 

The problem is, guest users don't have edit permissions. As a result, if a user tries to donate with an older email, he wouldn't be able to as the program wouldn't allow him to edit the older contact record. How can I work my way around this?

 

I'm currently writing this in a sandbox, and I notice that the guest user is using up data space. Would this be any different in production?

 

Please feel free to ask for clarification or for copies of my code. Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
oj2131oj2131

By the way, I got it working with a guest user license. No idea how, but I did.

All Answers

colemabcolemab

The guest user for the site can't be assigned the edit/delete/view all /modify all permissions for standard objects. This is by default and I think it is designed for security - salesforces believes you should be using authenticated user licenses (which cost money but are cheaper than normal licenses) for this kind of activity on sites.

 

Options might include:

Using custom objects and assigning the edit permission - not great if you are using built in objects already

Using apex controller without sharing  - huge security risk as the controller would basically run in admin mode.

 

 

oj2131oj2131

Thanks for your reply! How would I implement an authenticated user license in a sandbox site?

 

Also, how can I view the records inserted by the guest account?

 

 

colemabcolemab

Olivier,  I am not exactly sure as we don't have that feature in our instance.   However, I think you will need to contact your sales person, purchase an authenticated user license package, once activated in your test system refresh your sandbox to have that feature copied over.

 

Your sharing settings will be the main thing that would prevent you from seeing the guest account's records.

oj2131oj2131

Is it possible that there are two guest users; one for the checkout site and one for paymentConnect?

colemabcolemab

Yes, that is possible but as both would be site guest users - neither would have the ablity to be assigned the edit/delete/view all /modify all permissions for standard objects.

 

So if you object is a build in / standard CRM object, you still won't be able to update it under those user's permissions.

oj2131oj2131

Is it possible to implement a non-guest license on a SalesForce site? I thought all site users had guest licenses by default. Would a guest have to log in, in order to access an authenticated license?

colemabcolemab

Please read this link which explains user license types. You may have to use custom objects to accomplish what you want.

oj2131oj2131

By the way, I got it working with a guest user license. No idea how, but I did.

This was selected as the best answer
colemabcolemab

That is great news.  Please be aware that if you used "without sharing" to get around the user permissions (see docs here) then you *may* have an increased security risk on that class.

 

If you ever fiqure it out, please reply with the answer so others can benefit.