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
dmchengdmcheng 

Workarounds for Sites page to update standard object?

Hello.  I have a client who wants external users to submit data via a Sites VF page and update Opportunity records.

Of course the Sites profile doesn't have permissions to update standard objects.  Furthermore, the client does not want to purchase portal licenses for these external users.

I am considering two workarounds and am wondering if they are possible:

1.  Write some Apex webservices and call them from the Sites page Visualforce controller.
-- Looking at the webservice documentation, this doesn't seem possible, but I thought I check to make sure.

2.  Have the Sites page create a custom object record instead, and then write a trigger to update the opp record using the custom object.
-- Will the trigger be running in the system context and be able to update the opp?

Thanks
David

Best Answer chosen by dmcheng
Adnubis LLCAdnubis LLC
Your first work around would work. you could build a custom rest endpoint and have your controller call out to it to perform the update. This would allow you to receive the results but gives the additional overhead of a callout to the same server you are already on. That being said, it would allow you to use a username/password that has permissions to update/create opportunities.

All Answers

Adnubis LLCAdnubis LLC
If you don't need to provide real time results back to the end user you could use a future method to do the update. Let them make the changes to the opportuntiy and then serialize it and pass it to a future method that deserializes and does the update. The biggest draw back here is that it happens out of the context of the pages current page and execution.
dmchengdmcheng
Thanks for your reply.  Unfortunately I need real-time results - I need to do some transaction processing and show the results.
Adnubis LLCAdnubis LLC
Your first work around would work. you could build a custom rest endpoint and have your controller call out to it to perform the update. This would allow you to receive the results but gives the additional overhead of a callout to the same server you are already on. That being said, it would allow you to use a username/password that has permissions to update/create opportunities.
This was selected as the best answer
Ken Koellner @ EngagewareKen Koellner @ Engageware
I wouldn't think that @future would help as @future will run in the context of the Site Guest User just like the original process.