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

tkalpa005
Tera Expert

Hi Chaitanya,



you can try



1:if(g_form.isNewRecord()){


alert('Your Message');


}


2:if(g_form.getValue('sys_updated_on') != '' || g_form.getValue('sys_updated_on') != null ){


alert('Your Message');


}


Hi Kalpataru,


Thanks for your reply, I have done that the code is as follows




function onSubmit() {



if(g_form.getValue("u_status")=='Draft' && confirm('Are you sure you want to save this record ? You will not be able to change The Release Type after Save/ Submit'))


  {


  g_form.setValue("u_status", 'In Progress');


}


else {


  return false;


}



}



this works totally fine. Now, when I click on Ok and save the form It gets save but if I want to modify the form after saving the release I am not able to save the changes. Any suggestions for this?




Thanks,


Chaitanya


Hi,



If   you want stay   on the same page after insert, then you can try



action.setRedirectURL(current);


Hi kalpataru,


In the above code, where do I put this action. I will elaborate it once again. I have a form, when i fill the values I get a confirm message with Ok and Cancel Button. Ok button saves the form and Cancel button goes back again. Cancel and Ok button works fine with this code.   Now in this form I want to fill some fields which are remaining in that form. so, i go back to form and add those fields and try to save it. This time I dont able to save and update the form. I should able   to update the form even after I save it. How can I achieve this with this code.? Thanks for your help.





Thanks,


Chaitanya


Hi Chaitanya,



Please Remove 'Return false' in your IF condition   try, it may help