Info Message Not Displaying in Service Operations Workspace for Change Request Conflicts

Haribabu1
Tera Contributor

Hello All,

 

if change request is conflict, the add info message not displaying in Service Operational workspace. but it is visible in change request sow view.

 

Could anyone assist in identifying the cause and suggest a resolution for this issue?

 

Thanks in advance,

Haribabu

1 ACCEPTED SOLUTION

Hi @Haribabu1 ,

Couple of things

GlideURL and GwtMessage().getMessage api not working on workspace, i have commented that and used top.location.href for workspace view.

 

HemanthM1_0-1753184295853.png

 

Result :

HemanthM1_1-1753184578823.png

 

Script for reference, Make sure to test before you use.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    function getSchedulingConflictMessage() {
        var startDateReadOnly = g_form.isReadOnly("", g_form.getControl("start_date"));
        var endDateReadOnly = g_form.isReadOnly("", g_form.getControl("end_date"));

        if (startDateReadOnly || endDateReadOnly)
            return new GwtMessage().getMessage("Scheduling conflict detected. Review the Conflicts form section.");
        if (top.location.href.indexOf("now/sow/record/change_request") > -1) {
            g_form.addInfoMessage("Scheduling conflict detected. Use the <a href='javascript&colon;void(0);' onclick='openNextAvailableTime()'>Scheduling Assistant</a> to avoid conflicts.");
        }

        return new GwtMessage().getMessage("Scheduling conflict detected. Use the <a href='javascript&colon;void(0);' onclick='openNextAvailableTime()'>Scheduling Assistant</a> to avoid conflicts.");

    }

    function showConflictNotification() {
        var showConflictMessage = g_scratchpad.show_conflict_message;

        if (showConflictMessage.property === "never") return false;
        if (showConflictMessage.property === "always") return true;

        var showNotification = showConflictMessage.preference;
        return showNotification;
    }

    //We don't want to render the warning and link to the conflict scheduler if we're in 'print' mode
    //var gURL = new GlideURL();
    // gURL.setFromCurrent();
    // var isPrint = !!gURL.getParam("sysparm_media");
    //if (!isPrint && newValue === "Conflict" && showConflictNotification()) {
    if (newValue === "Conflict" && showConflictNotification()) {
        g_form.addWarningMessage(getSchedulingConflictMessage(), "conflict_warn_status");
        if (window && window.refreshConflicts)
            window.refreshConflicts();
        return;
    } else if (isLoading || newValue === '')
        return;

    // Remove the warning message as status is not Conflict.
    var chgGlideUI = GlideUI.get();
    var messageKey = "warning_" + getSchedulingConflictMessage();

    if (!chgGlideUI.messages[messageKey])
        return;

    delete chgGlideUI.messages[messageKey];

    var messageCount = Object.keys(chgGlideUI.messages).length;
    if (messageCount === 0)
        chgGlideUI.clearOutputMessages();
    else {
        var msgElement = $("conflict_warn_status");
        if (msgElement)
            msgElement.remove();
    }

    if (window && window.refreshConflicts)
        window.refreshConflicts();
}

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

10 REPLIES 10

Hi @Haribabu1 ,

 

Can you change UI Type to All and try

HemanthM1_0-1753107326250.png

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hello @Hemanth M1 ,

 

I have tried the above-mentioned scenario, but it didn't work. 

 

Thanks,

Haribabu

Hi @Haribabu1 ,

Couple of things

GlideURL and GwtMessage().getMessage api not working on workspace, i have commented that and used top.location.href for workspace view.

 

HemanthM1_0-1753184295853.png

 

Result :

HemanthM1_1-1753184578823.png

 

Script for reference, Make sure to test before you use.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    function getSchedulingConflictMessage() {
        var startDateReadOnly = g_form.isReadOnly("", g_form.getControl("start_date"));
        var endDateReadOnly = g_form.isReadOnly("", g_form.getControl("end_date"));

        if (startDateReadOnly || endDateReadOnly)
            return new GwtMessage().getMessage("Scheduling conflict detected. Review the Conflicts form section.");
        if (top.location.href.indexOf("now/sow/record/change_request") > -1) {
            g_form.addInfoMessage("Scheduling conflict detected. Use the <a href='javascript&colon;void(0);' onclick='openNextAvailableTime()'>Scheduling Assistant</a> to avoid conflicts.");
        }

        return new GwtMessage().getMessage("Scheduling conflict detected. Use the <a href='javascript&colon;void(0);' onclick='openNextAvailableTime()'>Scheduling Assistant</a> to avoid conflicts.");

    }

    function showConflictNotification() {
        var showConflictMessage = g_scratchpad.show_conflict_message;

        if (showConflictMessage.property === "never") return false;
        if (showConflictMessage.property === "always") return true;

        var showNotification = showConflictMessage.preference;
        return showNotification;
    }

    //We don't want to render the warning and link to the conflict scheduler if we're in 'print' mode
    //var gURL = new GlideURL();
    // gURL.setFromCurrent();
    // var isPrint = !!gURL.getParam("sysparm_media");
    //if (!isPrint && newValue === "Conflict" && showConflictNotification()) {
    if (newValue === "Conflict" && showConflictNotification()) {
        g_form.addWarningMessage(getSchedulingConflictMessage(), "conflict_warn_status");
        if (window && window.refreshConflicts)
            window.refreshConflicts();
        return;
    } else if (isLoading || newValue === '')
        return;

    // Remove the warning message as status is not Conflict.
    var chgGlideUI = GlideUI.get();
    var messageKey = "warning_" + getSchedulingConflictMessage();

    if (!chgGlideUI.messages[messageKey])
        return;

    delete chgGlideUI.messages[messageKey];

    var messageCount = Object.keys(chgGlideUI.messages).length;
    if (messageCount === 0)
        chgGlideUI.clearOutputMessages();
    else {
        var msgElement = $("conflict_warn_status");
        if (msgElement)
            msgElement.remove();
    }

    if (window && window.refreshConflicts)
        window.refreshConflicts();
}

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hello @Hemanth M1 ,

 

Thank you for your support and for sharing the code.

 

I’m pleased to inform you that it is functioning as expected in both the Native UI and the Service Operational Workspace.

 

I have a couple of follow-up questions regarding the code implementation:

  1. Could you please explain the purpose of the following lines?

if (window && window.refreshConflicts)
        window.refreshConflicts();

2. If we comment out the GlideURL and GwtMessage() .getMessageand and replace it with window.refreshConflicts(), would that impact the functionality in any way—such as performance degradation or unexpected behavior?

 

Thanks,

Haribabu

 

 

Hi @Haribabu1 

1.we didn't introduce these below lines, there were there already to refresh conflict on the fly when it exist

if (window && window.refreshConflicts)
        window.refreshConflicts();

2. We have commented GlideURL this wouldn't impact anything since it was checking the print screen window

3.We have put a if condition to check the workspace URL and run g_form.addInfoMessage for workspace and continue to run GwtMessage().getMessage() this for native UI

you should be good here...

 

Hope it helps if so,

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025