Giving alert pop up for the first save only

chaitanya_k333
Kilo Explorer


Hello All, I have given an alert message to a form. When I fill the form and click on Save button an alert gets generated. For this. I have written a simple client script. The code is

 

 

function onSubmit() {

    alert('" Are you sure you want to save this record ? You will not be able to change The Type after Save/ Submit."');

   

}

This is working accordingly when i Click on save button and saving it for the first time. Now the problem is occuring when I am doing any changes in the same form again and clicking save button, the same pop up is appearing again and again. How can I modify it like only for the first save, the alert should get triggered not when I am modifying the form again and clicking on save button. Please suggest

17 REPLIES 17

If this is in a workflow you may need to adjust when the workflow starts so


drafts can be edited before requesting approval etc.



On Thursday, 27 November 2014, Chaitanya kshirsagar <


Hello Gareth,


Its not a Workflow, its just runs on a client script.




Thanks,


Chaitanya


Anurag Tripathi
Mega Patron
Mega Patron

Hi Chaitanya,



If the record is being saved for the first time, ie, its not already present in the db , its sys_id in the current URL is -1.


You can check this by clicking new or create new on any record anywhere. So all you have to do here is read the URL and look for the parameter sys_id.


if(sys_id==1)


{


alert("*****");


}


-Anurag