Flow Context UI Action not working in Service Operations Workspace

jlaue
Kilo Sage

Hello - I am trying to get our 'Flow Context' UI Action on the RITM table to work within Service Operations Workspace.  The UI Actions opens the flow designer flow that is executing from the RITM.  The option shows up in the Form Menu, however, once I click on it, nothing happens.  I don't receive an error or anything, nothing happens after clicking.

 

I copied the code from the 'Script' field into the Workspace Client Script field, but that doesn't seem to work from what I am experiencing.  

 

jlaue_0-1736202405238.png

 

function onClick(g_form) {
    var url = new GlideURL('catalog_flow_context.do');
    url.addParam('sysparm_sys_id', g_form.getUniqueValue());
    url.addParam('sysparm_ck', g_form.getValue("sysparm_ck"));
    g_navigation.open(url.getURL(), "_blank");
}
 
Guessing something needs to be modified in the Workspace Client Script field, just not sure what?
 
Thanks!!

 

 

1 ACCEPTED SOLUTION

@jlaue 

this code worked for me

function onClick(g_form) {
    var gr = new GlideRecord("sys_flow_context");
    gr.addQuery("source_record", g_form.getUniqueValue());
    gr.query(checkRecord);
    function checkRecord(gr) {
        if (gr.next()) {
            var url = '/now/workflow-studio/builder?tableName=sys_flow_context&builderId=flow-execution&sysId=' + gr.sys_id;
            open(url);
        }
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

6 REPLIES 6

Thank you very much for the code, it is working perfectly now, thanks!!!

Community Alums
Not applicable

Hi @jlaue ,

When adapting a UI Action for use in the Service Operations Workspace (SOW), there are a few things to keep in mind. The client script in the workspace operates differently compared to traditional UI Actions. Workspace uses the declarative action framework, and you need to adjust your approach accordingly.

In Workspace, the g_form object does not behave exactly as it does in the classic UI.

You need to use action APIs provided by Workspace.

try with this code

 

 

function executeAction() {
    // Get the sys_id of the record
    var sysId = action.getGlideRecord().getValue('sys_id');

    // Construct the URL to the Flow Context
    var url = new GlideURL('catalog_flow_context.do');
    url.addParam('sysparm_sys_id', sysId);
    url.addParam('sysparm_ck', g_ck); // Use 'g_ck' if it's available in your session

    // Open the Flow Context in a new tab
    window.open(url.getURL(), '_blank');
}