Giving alert pop up for the first save only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 01:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 02:17 AM
Create a field on the form which will count how many times Save button is clicked.
Then when first time,save button is clicked the field value exceeds to 1 ,then execute script.
Thanks,
Hiranmayee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 02:21 AM
Use g_form.isNewRecord() in if condition. More information in below link.
GlideForm (g form) - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 02:30 AM
Hi Chaitanya,
Create on display business rule and store the operation;
g_scratchpad.operation_type = current.operatiopn();
In onsubmit script.
function onSubmit() {
if(g_scratchpad.operation_type == 'insert');
{
alert('" Are you sure you want to save this record ? You will not be able to change The Type after Save/ Submit."');
}
else
{
continue;
}
}
Regards,
Harish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 02:54 AM
yes. first save and insert are one and the same.so insert BR would work in this case.