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.

CMDB Workspace Related List create UI Action Button

tomeczek1
Tera Contributor

I have created a UI Action for one of the custom m2m related lists.
The UI Action is of client type. When I click the New button, a new form opens, but I need to pass some parameters in the query to limit the options in the reference fields. This works as expected in the Classic UI, but not in Workspace.

I discovered that there is a separate Workspace Related Action module where I can create a dedicated button for Workspace. I was able to create it and pass the parameters in the query, but the new form does not open as expected. I would like it to open within the breadcrumbs to make navigation easier. Instead, it reloads the entire browser window, and the breadcrumbs display as Home -> New Record, which is not ideal. I want to have HOME-> CMDB->Application Access-> New m2m table record 

Could you please advise on how to improve the client script, or should I create a Workspace UI Action button differently? 

 

Here is the classic UI Action script 

"

function redirect() {
    var url = new GlideURL('/u_m2m_user_application_access.do');
    url.addParam('sys_id', '-1');
    if (g_form.getTableName() == 'cmdb_ci_business_app') {
        // u_business_application field is used in refqual on u_application_service field
        // we don't use this field for any other purpose (and shouldn't)
        url.addParam('sysparm_query', 'u_business_application=' + g_form.getUniqueValue());
    }
    else {
        url.addParam('sysparm_query', 'u_application_service=' + g_form.getUniqueValue());
    }
    g_navigation.open(url.getURL());
}"
 
I want the same to be achieved in Wrokspace, here is the current sciprt, that works but open  a tab NOT in the breadcrumbs
"
function onClick() {
    var tableName = g_form.getTableName();
    var uniqueValue = g_form.getUniqueValue();
    var queryParam = (tableName === 'cmdb_ci_business_app') ? 'u_business_application=' : 'u_application_service=';
    var link =  "now/cmdb/home/sub/record/u_m2m_user_application_access/-1/params/query/" + queryParam + uniqueValue;
 
    var win = top.window.open(link, '_self');
}"
 
Can you please advise?
0 REPLIES 0