How to clear field value when "Leave sit" dialog box is "Cancel"

Salah2
Tera Contributor

Hi all,

Is possible to clear field value when when "Leave sit" dialog box is "Cancel" 

 

Salah2_0-1721678900209.png

 

Salah2_1-1721679163042.png

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.  

 

1 REPLY 1

shreedevin
Giga Guru
Giga Guru

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