how to show a pop up with yes or no rather that ok comformation button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 10:35 PM
hi can anyone help me with the code for scenario for 'When selecting Cancel in an Incident, please add a pop up window that asks, "Are you sure you want to cancel this incident?" Give a yes or no option. If yes, proceed with the cancel. If no, then force them to make a new selection.'
i have written below code but im not getting yes or no type :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var value = g_form.getValue('incident_state');
if (value == 15) {
var answer = confirm('Are you sure for cancelling this incident');
if (answer == 'Yes') {
g_form.save();
} else {
g_form.setValue('incident_state', oldValue);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 10:41 PM
Hi @raj765_32
Instead of onChange, you should be doing onSubmit client script and add a check for cancel state:
var value = g_form.getValue('incident_state');
if (value == 15) {
var answer = confirm('Are you sure for cancelling this incident');
if (!answer) {
return false;
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 10:47 PM
Hi @raj765_32
Please refer below link
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 10:57 PM - edited 03-05-2024 10:57 PM
@raj765_32 , Not sure if this is Possible to change this button labels from cancel/No to yes or no and as Aman Said you need to Design On submit not on change , so when user changes Incident State to Cancel and Save the Record it shows pop up to proceed with Cancel or Stay on the Same state
if you really Want to have the Yes/NO button so you might need to create Custom UI Page for this
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 11:06 PM
Your code looks mostly correct, but the issue lies in how you're checking the user's response to the confirmation prompt. The confirm() function returns a boolean value (true if the user clicks "OK" and false if the user clicks "Cancel"), not a string "Yes" or "No".
Here's the corrected version of your code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var value = g_form.getValue('incident_state');
if (value == 15) {
var answer = confirm('Are you sure you want to cancel this incident?');
if (answer) {
// If user clicks OK (true)
g_form.save();
} else {
// If user clicks Cancel (false)
g_form.setValue('incident_state', oldValue);
}
}
}