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
Rita LeverettRita Leverett 

Authorization Required displays after successful insert

Hello,

I create a new Site and Visualforce page form to collect survey data from a public site and insert a record into a custom object. All the records are there with complete data. The problem is that the Authorization Required displays after saving the form. Debug Log only shows which VF pages are being accessed and no error. I viewed as Admin and the authorization error referenced the ID of the record that was successfully created. I've tried every permission from Read Create to Read, Create, Edit, and Delete but same result; records are created but the error page displays.

I haven't tried to redirect from the form after completion, although rerender didn't help. I am using standardController with my custom object. Maybe I'm missing some Apex and need to write a controller? Any assistance is appreciated.
Best Answer chosen by Rita Leverett
Gordon EngelGordon Engel
Ah, in that case, I think the VF controller returns the URL that the user should be directed to after submitting. If you set that, then it should send the user to somewhere he can access.

https://developer.salesforce.com/forums/?id=906F00000008z46IAA

All Answers

Gordon EngelGordon Engel
When you say "new Site", are you talking about Communities?  Guest users have very restricted access, and you have to set up Sharing rules for them.  See: https://trailhead.salesforce.com/modules/community_rollout_impl/units/community_rollout_impl_sharing
Rita LeverettRita Leverett
Thanks for your quick response.

No, not Communities. It's an embedded form (or will be) on a website. I set up a new Site in Force.com Sites, created a Visualforce page for the form, and set up the Site Guest User to have permissions on the VF page and the custom object (which does not reference any other object). As I said, records are created just fine. Of course, there is no error when the form is used within Salesforce.
Gordon EngelGordon Engel
I still suspect sharing rules apply just as they do in a Community.  I have to admit that this isn't my area of expertise.  You are referring to permissions on the object, but you also need to check sharing IIRC.
Rita LeverettRita Leverett
Are you referring to Org-Wide Sharing (set as Public Read/Write) or something else? The Site Guest User is the record owner so I'm not sure what sharing rules would apply here. Am I missing something?
Rita LeverettRita Leverett
I should clarify that this is just an online form. Submitters aren't supposed to have access to view or edit after the fact.
Gordon EngelGordon Engel
Ah, in that case, I think the VF controller returns the URL that the user should be directed to after submitting. If you set that, then it should send the user to somewhere he can access.

https://developer.salesforce.com/forums/?id=906F00000008z46IAA
This was selected as the best answer
Rita LeverettRita Leverett
Ok, that makes sense. I'll give it try, thanks!
Rita LeverettRita Leverett
That did the trick! Redirection was the key. Thank you, Gordon!