Alert message onChange Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 06:41 AM
Hi all,
I could use some help with what I'm trying to accomplish. I'm trying to create an alert message when the disposition is set to cancelled. Ideally I would like to have the alert message show onChange but I would like a cancel option on the alert message and then have the values return back to what they were before.
Here is my code so far:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Alert message if dispostion changes
if (oldValue != newValue)
alert('You changed the disposition to ' + newValue + '. Cancelling this Demand item will cancel all associated tasks as well. Are you sure you want to continue?');
g_form.setValue('cancelled', oldValue);
}
This is a client script, onChange
Thank you in advance!
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 06:45 AM
Hello James,
You can write return false after your alert statement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 06:46 AM
Hi James,
You can use confirm in onsubmit client script to achieve this requirement . Use Code as below
function onSubmit() {
var input = g_form.getValue('<field name>');
alert(input);
if (input == 'Win') {
var answer = confirm("Please click Ok to continue your order.");
if (answer == false){
return false;
}
}
}
Hope this helps.
Regards
Ujjawal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 06:47 AM
You can try Confirm instead of Alert.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 06:51 AM
Also if you want the value as previous value then you can set the field to oldValue. Use script as mentioned below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Alert message if dispostion changes
if (oldValue != newValue)
var answer = confirm("You changed the disposition to ' + newValue + '. Cancelling this Demand item will cancel all associated tasks as well. Are you sure you want to continue?");
if (answer == false){
return false;
g_form.setValue('<field name>', oldValue);
}
}
Regards
Ujjawal