Client Script for enabling edit button

aparnaravi
Tera Contributor

I have configured an Edit button in the related list of an RITM in SOW. However, I need a client script for the onclick event to allow selecting RITMs from there. I have tried some scripts,but they are not working, and when I try to save, the changes are not being saved.  I have created a related list action for edit and added the table sc_req_item and view Service Operation Workspace

1 ACCEPTED SOLUTION

Hi,

Check all the steps again specially the payload mapping and event mappings. It should work.

There is the another way to add child RITMs

1. Create a new action "Edit"

Shruti_0-1753260850265.png

2.  Client script 

function onClick() {
    var parentRITM = g_form.getUniqueValue(); // current RITM sys_id

    var _strLink =
        '/sys_m2m_template.do?' +
        'sys_is_list=true&' +
        'sys_is_related_list=true&' +
        'sysparm_collectionID=' + parentRITM + '&' +
        'sysparm_query=&' +
        'sysparm_referring_url=' + location.pathname + '&' +
        'sysparm_stack=no&' +
        'sys_target=sc_req_item&' +
        'sysparm_m2m_ref=sc_req_item&' +
	'sysparm_form_type=o2m&'+
        'sysparm_collection=sc_req_item&' +
        'sysparm_collection_key=parent&' + 
        'sysparm_collection_label=RequestItems&' +
        'sysparm_collection_related_field=&' +
        'sysparm_collection_related_file=sc_req_item&';

    var win = top.window.open(_strLink, '_self');
    if (win) {
        win.focus();
    }
}

 

View solution in original post

13 REPLIES 13

I have updated the action payload, but the issue still persists. I can't add RITMs — the Add button is not clickable. When we click on the Add button, it should display the list of RITMs, but that is not happening

Hi,

Check all the steps again specially the payload mapping and event mappings. It should work.

There is the another way to add child RITMs

1. Create a new action "Edit"

Shruti_0-1753260850265.png

2.  Client script 

function onClick() {
    var parentRITM = g_form.getUniqueValue(); // current RITM sys_id

    var _strLink =
        '/sys_m2m_template.do?' +
        'sys_is_list=true&' +
        'sys_is_related_list=true&' +
        'sysparm_collectionID=' + parentRITM + '&' +
        'sysparm_query=&' +
        'sysparm_referring_url=' + location.pathname + '&' +
        'sysparm_stack=no&' +
        'sys_target=sc_req_item&' +
        'sysparm_m2m_ref=sc_req_item&' +
	'sysparm_form_type=o2m&'+
        'sysparm_collection=sc_req_item&' +
        'sysparm_collection_key=parent&' + 
        'sysparm_collection_label=RequestItems&' +
        'sysparm_collection_related_field=&' +
        'sysparm_collection_related_file=sc_req_item&';

    var win = top.window.open(_strLink, '_self');
    if (win) {
        win.focus();
    }
}

 

This script solved the problem. Thank You so much

@aparnaravi 

did you check this link?

SOLVED: Workaround for "Edit ..." buttons on Related Lists of Workspaces 

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