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

Hi,


This may help you


var cnfrm='';



if(g_form.getValue("u_status")=='Draft'){


cnfrm=confirm('Are you sure you want to save this record ? You will not be able to change The Release Type after Save/ Submit');


  if(cnfrm){


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


  }


  }else if(cnfrm== false)


    return false;


}


Yes. The code is totally fine. Thank you. just a small issue now.



When I select Ok. and Submit the form. my workflow is getting triggered. For eg, on selecting a Type, I will get Phases according to the type. but it is also getting triggered when I click on cancel to backout from submission. The workflow is still getting triggered. I can able to modify contents even after my form submission which is totally fine. but, when I modify the release type over previous 1 and save the form again, Phases are getting overwritten. both previously selected Release type and new Release type are displaying. Is it possible to show only selected release type phases should be displayed?



If i use the else return false; in the code , phases are not getting triggered but, I not able to update the form.



Thanks,


Chaitanya


salemsap
Tera Expert

Hi,


just add "updates" in form and hide it on loading using UI policy or client script.This field(updates) will automatically increase the count by 1 on every update.So you can use this in your script.


If(g_form.getValue('sys_mod_count') == 0)


{


alert(msg);


}


gbernie
Kilo Expert

Hi Chaitanya,



I have something similar set up for our end of year change freeze where a alert is required when a new change is raised.


Below is the code with your words used in the alert.



function onSubmit() {


    if(g_form.isNewRecord()){


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


    }


}



This works for me.


Hi Gareth,


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 form I am not able to   alter the changes in the saved form I want to add this functionality to it. Any suggestions for this?




Thanks,


Chaitanya