How to clear field value when "Leave sit" dialog box is "Cancel"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:16 PM
Hi all,
Is possible to clear field value when when "Leave sit" dialog box is "Cancel"
Variable name: deadline_submission
type: yes/no
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
if (newValue === "No") {
var redirectURL = '/core?id=sc_cat_item&sys_id=';
top.window.location.href = redirectURL;
}
}
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 03:12 PM
Hi,
Try this
// Client Script: Clear Field Value on Dialog Cancel
function onLoad() {
// Assume that we are using a GlideModal to create the dialog box
var dialog = new GlideModal('Leave sit');
dialog.setTitle('Leave site?');
dialog.setBody('<p>Are you sure you want to leave the site?</p>');
// Add Cancel button
dialog.addCancelButton('Cancel', function() {
// Clear the field value when cancel is clicked
g_form.setValue('your_field_name', '');
dialog.destroy();
});
// Add other buttons/actions as needed
dialog.addOKButton('OK', function() {
// Handle OK action
dialog.destroy();
});
// Show the dialog
dialog.render();
}
Please mark this response as correct or helpful if it assisted you with your question.
Thanks and Regards
Shreedevi