You need to sign in to do that
Don't have an account?
mdinatale
Update record on page load
Im trying to insert data when the vF page loads, Whats the best way to do this. I either get a DML error or page not commited. Page not commited the data goes into the object but gives the error. Any help would be apreciated
This is generally not recommended as it can leave the page open to cross site request forgery attacks - essentially you are executing DML from a GET: http://wiki.developerforce.com/page/Secure_Coding_Cross_Site_Request_Forgery
That said, there's a couple of ways I've done this in the past:
(1) Insert a "staging" page that carries out the insert via an action method specified on the page component, then redirects to the real page.
(2) Have some javascript executed at page load tied to an actionfunction that calls an action method to execute the DML.
All Answers
This is generally not recommended as it can leave the page open to cross site request forgery attacks - essentially you are executing DML from a GET: http://wiki.developerforce.com/page/Secure_Coding_Cross_Site_Request_Forgery
That said, there's a couple of ways I've done this in the past:
(1) Insert a "staging" page that carries out the insert via an action method specified on the page component, then redirects to the real page.
(2) Have some javascript executed at page load tied to an actionfunction that calls an action method to execute the DML.
ive tried the action functioin way but get the same error. Can you give me a example of how you would do it. Ive seen examples but none seem to work. The data goes in but then i get the error
I don't have an example I'm afraid. If you post up your code I can take a look at that.