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
abi060988abi060988 

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.

Navatar_DbSupNavatar_DbSup

Hi,


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" >
<script>
Alert(‘opportunity successfully saved’);
</script>
</apex:page>

 

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

JitendraJitendra

Hi Abhi,

Try below code :

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

</apex:page>

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