+ Start a Discussion

Execute javascript in Save Button

Whenever I create/update a opportunity in Salesforce, it should pop up a confirmation message. I found a JavaScript function but I don’t know how to use this in save button of a record.



If you are working on the standard page (on object) of the salesforce then you cannot display the alert on the save button click. The alternative for that you can create a VF page in which you can display the alert message and insert that page in the Visual Force page section of the standard object page layout.
For example
<apex:page standardController="account" >
Alert(‘opportunity successfully saved’);


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


Hi Abhi,

Try below code :

<apex:page controller="PassParameterActionFunction">
<apex:form id="frm">
<apex:commandButton id="GetMessage" oncomplete="promptMsg()" action="{!test1}" />
<script type="text/javascript">
function promptMsg()
 alert('Calling After Execute');


 "oncomplete" attribute can used to execute javascript after execution.