Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Customized Edit Action in RITM Approvers Related(SOW) List Not Working After Australia Upgrade

FemyM
Tera Contributor

 

We are experiencing an issue with a customized Edit Declarative Action in the Approvers related list on the Requested Item (RITM) in SOW after upgrading our ServiceNow instance to the Australia release.

The Edit functionality was customized using a Declarative Action with a Client Script to open the sys_m2m_template.do page and allow users to manage approvers.

The Client Script used in the Declarative Action is:

 

 
function onClick() {
    var _strLink =
        '/sys_m2m_template.do?' +
        'sys_is_list=true&' +
        'sys_is_related_list=true&' +
        'sysparm_collectionID=' + g_form.getUniqueValue() +
        '&sysparm_query=' +
        '&sysparm_referring_url=' + location.pathname +
        '&sysparm_stack=no' +
        '&sys_target=sysapproval_approver' +
        '&sysparm_m2m_ref=sysapproval_approver' +
        '&sysparm_collection=sc_req_item' +
        '&sysparm_collection_key=sysapproval' +
        '&sysparm_collection_label=Approvers' +
        '&sysparm_collection_related_field=approver' +
        '&sysparm_collection_related_file=sys_user&';

    var win = top.window.open(_strLink, '_self');

    win.focus();
}
 

 

 

Issue

This customization was working as expected before the Australia upgrade.

After the upgrade:

  • The customized Edit Declarative Action is displayed.
  • Clicking the button does not execute the expected Client Script.
  • The sys_m2m_template.do page/slushbucket does not open.
  • No error message is displayed.
  • The page remains unchanged.

As a basic test, we also replaced the Client Script with:

 

 
function onClick(g_form) {
    alert('Test action executed');
}
 
 

However, the alert is not triggered either.

4 REPLIES 4

Ankur Bawiskar
Tera Patron

@FemyM 

if this was working fine before upgrade then raise a case with ServiceNow.

any browser console error?

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

Hi @Ankur Bawiskar ,
Raised a case with ServiceNow; however, since this involves a customization, there are limitations on the level of support they can provide.

@FemyM 

that's true.

don't use alert, try to use console.log() to debug

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

Vishal Jaswal
Tera Sage

Hello @FemyM 

Below declarative action works in both Zurich as well as in Austrailia. I have tried explaining the solution in the code comments:

function onClick(gForm) {    

    // extract sys_id of current ritm by splitting the current URL https://instance.service-now.com/now/sow/record/sc_req_item/aec79906.../params/...
    
    var ritmSysId = '';
	//not using g_form.getUniqueValue() because it doesn't work well with workspace                                   
    var urlParts = location.href.split('/sc_req_item/');   // Split URL at '/sc_req_item/' — everything after this is what we need. 
    
    // If the URL contains '/sc_req_item/', urlParts will have 2 pieces.
    // The second piece starts with the sys_id, followed by '/' and other stuff.
    if (urlParts.length > 1) {
        ritmSysId = urlParts[1].split('/')[0];             // Take everything before the next '/' — that's just the sys_id
    }
    
    //if we somehow couldn't find the sys_id or user is on an unexpected page, stop here to avoid opening a broken slushbucket URL. Better to do nothing
    if (!ritmSysId)
	return;
       

    // you are building below URL for     
    var slushbucketUrl = '/sys_m2m_template.do?' +
        'sys_is_list=true&sys_is_related_list=true' +
        '&sysparm_collectionID=' + ritmSysId +               // RITM
        '&sys_target=sysapproval_approver' +
        '&sysparm_m2m_ref=sysapproval_approver' +
        '&sysparm_collection=sc_req_item' +
        '&sysparm_collection_key=sysapproval' +
        '&sysparm_collection_label=Approvers' +
        '&sysparm_collection_related_field=approver' +
        '&sysparm_collection_related_file=sys_user' +
        '&sysparm_stack=no';    
    

   // you are opening slushbucket in new tab using function declared below
       
    openUrl(slushbucketUrl);
}

 //Function: Opens a URL in a new browser tab
function openUrl(targetUrl) {
    this.open(targetUrl, '_blank'); // not using top.window.open(url, '_self') because it doesn't work well with workspace
}

VishalJaswal_7-1787782794870.png

 


Validation Results: 


VishalJaswal_3-1787782419946.png

Slushbucket to add remove members opened successfully in new tab:

VishalJaswal_4-1787782452530.png


Approvers added successfully:

VishalJaswal_5-1787782464923.png


Similarly, removed:

VishalJaswal_6-1787782485184.png

 


Hope that helps!