I have a custom object that I want to create records for from a VF page on Sites. I am presenting a handful of input fields and a "save" button, and want to present a message when the save is successful.

The Sites user profile has permissions to the VF page and the associated custom controller, as well as create/edit on the custom object and all its fields. As part of a custom save() method, I redirect to a new page (to which the Sites user also has access) to display the 'submitted' message; then a trigger on the custom object takes over. The actions class called by the trigger is also available to the Sites user.

From the debug log the controller appears to be working correctly, as well as the initial processing of the trigger, but then I get the 'Insufficient Privileges' error:

CODE_UNIT_FINISHED| on trigger event BeforeInsert for [new]
VF_PAGE_MESSAGE|Insufficient Privileges

The after insert trigger uses the new record's Id to create another type of object, and the Sites user has create/update on that object and the relevant fields as well.

How can I figure out what privileges are missing? Not being able to login as the Sites user from the UI feels very limiting.


Check your OWD / Sharing settings for the object and any relationships you're setting. If any of those are set to anything other than public read / write, then you will likely not be able to insert the record as a generic sites user.

|improve this answer|||||
  • 2
    Good call! I changed my lookup() to text just to hold the related id and the save() processed. (I wonder if the relationship works the other way 'round, i.e. if I reverse the lookup() relationship will it work -- I'll know in a moment.) – Duncan Stewart Apr 16 '14 at 18:41
  • 2
    Okay, so rather than creating the relationship by putting the lookup() on the Sites-ready object (sro), I used a text field on the sro and created the lookup() going the other way (from Sites-hidden object to sro). This works fine. – Duncan Stewart Apr 16 '14 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.