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

Unable to create UI Action button in workspace.

dusmantanayak
Tera Contributor

Hi,

 

I have created one UI Action button on incident form but unable to populate the button in service operation workspace. Please help me with the issuue.

Script:

function sendIncidentTolenovo() {
    if (g_form.getValue('work_notes') == '') {
        var workNotes = g_form.getValue("work_notes");
        var affectedUser = g_form.getValue("u_affected_user"); // Get the caller
        var gm = new GlideModal("x_telu6_th_lenovo_modal_popup_for_work_notes");
        gm.setTitle("Incident Details");
        gm.setPreference("work_notes", workNotes);
        gm.setPreference("u_affected_user", affectedUser); // Pass the caller to the UI Page
        gm.setSize(600, 400);
        gm.render();
        return false;
    }
    //!current.isNewRecord() && current.active == true && current.correlation_id.toString().indexOf('Lenovo') == -1 && new x_telu6_th_lenovo.THLenovoUtils().isUserInAllowedGroups()
}
 
Workspace script:
 
function onClick(g_form) {

    1. Get values from the Workspace form
    var workNotes = g_form.getValue("work_notes");
    var caller = g_form.getValue("caller_id");

    // 2. Define your UI Page name
    var uiPageName = "x_telu6_th_lenovo_modal_popup_for_work_notes";

    // 3. Open the Modal in Workspace
    // Note: We pass parameters via the URL query string for Workspace frames
    g_modal.showFrame({
        title: "Incident Details",
        url: uiPageName + ".do?sysparm_caller_id=" + caller + "&sysparm_work_notes=" + encodeURIComponent(workNotes),
        size: 'lg',
        height: 500
    });
    var caller = g_form.getValue("caller_id");
    var workNotes = g_form.getValue("work_notes");
    var uiPage = "x_telu6_th_lenovo_modal_popup_for_work_notes";

    // Pass sysparm_workspace=true so the UI Page knows its environment
    var url = uiPage + ".do?sysparm_workspace=true&sysparm_caller_id=" + caller + "&sysparm_work_notes=" + encodeURIComponent(workNotes);

    g_modal.showFrame({
        title: "Incident Details",
        url: url,
        size: 'lg',
        height: 500
    });
}
 
Regards,
Dusmanta
2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron

@dusmantanayak 

Ensure "Format For Configurable Workspace" checkbox is True

Remove line 3

AnkurBawiskar_0-1771218581133.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Hello @dusmantanayak ,

 

I hope you are doing well. Does my response helps you ?

 

If my response helps you then mark it as helpful and accept as solution.

You can accept multiple solutions 😀 .

 

Regards,

Aditya,

Technical Consultant

View solution in original post

6 REPLIES 6

Tanushree Maiti
Giga Sage

Hi  dusmantanayak

Please ensure in your UI button configuration  "Format for Configurable Workspace" is checked. Then try.

 

TanushreeMaiti_0-1771163827264.png

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Ankur Bawiskar
Tera Patron

@dusmantanayak 

Ensure "Format For Configurable Workspace" checkbox is True

Remove line 3

AnkurBawiskar_0-1771218581133.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader