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.

Display dialog box with 'Yes' and 'No' option using onSubmit Client Script

Rush B
Tera Contributor

Hi ,

I need to create a dialog box to show some text with 'Yes' and 'No' as the button for the user to choose. If user selects 'Yes" need to update a Boolean field as true and if 'No' then update same Boolean field as false, I need to do this using onSubmit Client Script. Please help with the working example!

2 ACCEPTED SOLUTIONS

Hello @Rush B 

For GlideModal approach you can try the below one:

function onSubmit() {
    //Type appropriate comment here, and begin script below
    if (g_scratchpad.userConfirmed) {
        return true;
    }
    var knowledgeTrue = function() {
        g_scratchpad.userConfirmed = true;
        g_form.setValue("knowledge", true);
        g_form.submit();
    };

    var knowledgeFalse = function() {
        g_scratchpad.userConfirmed = true;
        g_form.setValue("knowledge", false);
        g_form.submit();
    };
    var glideDialogClass = typeof GlideModal != 'undefined' ? GlideModal : GlideDialogWindow;
    var gModal = new glideDialogClass("glide_ask_standard");
    gModal.setTitle("Are you want to create article upon closure?");
    gModal.setPreference("title", "Article creation");
    gModal.setPreference("onPromptComplete", knowledgeTrue);
    gModal.setPreference("onPromptCancel", knowledgeFalse);
    gModal.render();

    return false;
}

(=tested)

 

Thanks,
Murthy

View solution in original post

4 REPLIES 4

Murthy Ch
Giga Sage

Hello @Rush B 
It's pretty straight forward! Have you tried anything so far?

 

Thanks,
Murthy

Rush B
Tera Contributor

GlideModal approach ? if yes pls help with the provide sample code, check the screenshot once I need to show like that.

Hello @Rush B 

For GlideModal approach you can try the below one:

function onSubmit() {
    //Type appropriate comment here, and begin script below
    if (g_scratchpad.userConfirmed) {
        return true;
    }
    var knowledgeTrue = function() {
        g_scratchpad.userConfirmed = true;
        g_form.setValue("knowledge", true);
        g_form.submit();
    };

    var knowledgeFalse = function() {
        g_scratchpad.userConfirmed = true;
        g_form.setValue("knowledge", false);
        g_form.submit();
    };
    var glideDialogClass = typeof GlideModal != 'undefined' ? GlideModal : GlideDialogWindow;
    var gModal = new glideDialogClass("glide_ask_standard");
    gModal.setTitle("Are you want to create article upon closure?");
    gModal.setPreference("title", "Article creation");
    gModal.setPreference("onPromptComplete", knowledgeTrue);
    gModal.setPreference("onPromptCancel", knowledgeFalse);
    gModal.render();

    return false;
}

(=tested)

 

Thanks,
Murthy

@Rush B GlideModalTask.gif

Thanks,
Murthy