Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Workspace yes and no popup

Sandeep8987
Tera Contributor

Hi,

function onClick() {

    var comments = g_form.getValue("comments");
    if (!comments) {
        alert('The "Additional comments" field must be filled in before the transtitioning to Canceled');
        return false;
    }	
g_modal.confirm('Confirmation', 'Are you sure you want to cancel this incident?', {
    cancelTitle: 'No',    // Custom label for the 'No' button
    confirmTitle: 'Yes'   // Custom label for the 'Yes' button
}).then(function() {
    // Executes if user clicks Yes
   
    g_form.setValue('incident_state', '8'); // Cancelled
    g_form.setValue('state', '8');
    g_form.submitAction("cancel_incident"); // Trigger server-side UI Action
}, function() {
    // Executes if user clicks No or closes the dialog
 
});

I have written the workspace client script for yes and no button while clicking upon cancel ui action button.
The popup up is coming with yes and no but clicking on yes or no it is not working. 
Anupam 

 

1 REPLY 1

Shruti
Mega Sage
Mega Sage

Hi @Sandeep8987 

Check this code

function onClick() {
    var comments = g_form.getValue("comments");

    if (!comments) {
        alert('The "Additional comments" field must be filled in before transitioning to Canceled');
        return false;
    }

    g_modal.confirm(
        'Confirmation',
        'Are you sure you want to cancel this incident?',
        function(confirmed) {
            if (confirmed) {
                g_form.setValue('state', '8');
                g_form.save();
            }
        }, {
            "cancelTitle": "No",
            "confirmTitle": "Yes"
        });

    return false;

}