You need to sign in to do that
Don't have an account?

calling javascript after saving visual force page
Hi, I have a visual force page that updates a contact record.
After saving the visual force page I need to fire off some javascript.
The javascript is ajax that creates a session connection and updates the Account object.
I have to use ajax because I am calling sforce.connection.assignmentRuleHeader to update the Account territory based on information coming from the page that is being saved. You cannot do this with a trigger or with apex code.
My question is, should i fire the javascript on the window.unload of the page or is their a better way?
Or should I call a 2nd vf page after saving 1st vf page and pass account id to 2nd vf page which contains javascript ajax calls?
Also the javascript has to know the account id.
How can I reference the account id of the current contact being displayed in the vf page?
Thanks, Kevin.
Hi Kevin,
window.unload event in javascript has some inconsistensies over different browsers. Instead of using page unload events, what you can do after performing save action in controller is to redirect to a vf page with account id as paramter. this vf will only have the javascript function that will run and update your account territory.
Cheers..