We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Confirmation Message with Yes or No options

tindiz
Giga Guru

Hello ServiceNow experts! I have this Client Script that has a confirmation message showing to copy fields from parent to child case. This confirmation message has options to select: OK (copy) and Cancel (not to copy). Please help in modifying to change the OK to Yes and Cancel to No. Here's the client script:

 

tindiz_0-1730875185143.png

 

 

 

function onLoad() {
    
    // Check if the form is a new record
    if (g_form.isNewRecord()) {
        // Clear the confirmation flags for new cases
        sessionStorage.removeItem('confirmationShown');
        sessionStorage.removeItem('descriptionConfirmationShown');

        var parentId = g_scratchpad.parentSysId;

        // Show confirmation for short description if not already shown
        if (parentId) {
            var confirmationShown = sessionStorage.getItem('confirmationShown');
            if (!confirmationShown) {
                var answer = confirm("Do you want to copy the short description from the parent case?");
                if (answer) {
                    var ga = new GlideAjax('GetParentFields');
                    ga.addParam('sysparm_name', 'getShortDescription');
                    ga.addParam('sysparm_parent_id', parentId);
                    ga.getXMLAnswer(function(response) {
                        if (response) {
                            g_form.setValue('short_description', response);
                        }
                    });
                }
                sessionStorage.setItem('confirmationShown', 'true');
            }

            // Show confirmation for description if not already shown
            var descriptionConfirmationShown = sessionStorage.getItem('descriptionConfirmationShown');
            if (!descriptionConfirmationShown) {
                var descriptionAnswer = confirm("Do you want to copy the description from the parent case?");
                if (descriptionAnswer) {
                    var gaDesc = new GlideAjax('GetParentFields');
                    gaDesc.addParam('sysparm_name', 'getDescription');
                    gaDesc.addParam('sysparm_parent_id', parentId);
                    gaDesc.getXMLAnswer(function(response) {
                        if (response) {
                            g_form.setValue('description', response);
                        }
                    });
                }
                sessionStorage.setItem('descriptionConfirmationShown', 'true');
            }
        }
    }
}

 

 

3 REPLIES 3

tindiz
Giga Guru

Can somebody help me please...

I got it working now.

Brielle Robinso
Tera Contributor

Hi, what did you do to get this working? Thanks