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

Hi,

1. Configure Request item related list in Service Operations Workspace view. Add Request item -> Parent related list

Shruti_0-1753194059161.png

 

2. Navigate to Now experience framework -> Related list action

Create a new action to Add child RITMs and check step 4th for specify client action

Shruti_2-1753245556857.png

 

3.Configure Action Configuration related list

Shruti_2-1753194173921.png

 

4.Create a client action 

Shruti_0-1753252161295.png

 

Payload

{
"label": "Add",
"userGivenTable": "sc_req_item",
"table": "{{table}}",
"parentRecordSysId": "{{parentRecordSysId}}",
"parentFieldName": "parent",
"referencedFieldName": "parent",
"extensionPoint": "",
"query":"parent=NULL",
"view": "Default",
"columns": "number,short_description",
"type": "o2m",
"hideSelectAll": false,
"relatedListName": "{{relatedListName}}",
"asyncProperties": {
"enableAsync": true,
"asyncThreshold": 50,
"relatedListLabelName": "{{label}}"
}
}

 

5. Create a new UX Add-on Event Mapping

Shruti_4-1753194349430.png

Shruti_5-1753194385817.png

Target Payload Mapping

{
"container": {
"fields": {
"container": {
"columns": {
"binding": {
"address": [
"columns"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"extensionPoint": {
"binding": {
"address": [
"extensionPoint"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"hideSelectAll": {
"binding": {
"address": [
"hideSelectAll"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"label": {
"binding": {
"address": [
"label"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"parentFieldName": {
"binding": {
"address": [
"parentFieldName"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"parentRecordSysId": {
"binding": {
"address": [
"parentRecordSysId"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"referencedFieldName": {
"binding": {
"address": [
"referencedFieldName"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"relatedListName": {
"binding": {
"address": [
"relatedListName"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"table": {
"binding": {
"address": [
"table"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"userGivenTable": {
"binding": {
"address": [
"userGivenTable"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"view": {
"binding": {
"address": [
"view"
]
},
"type": "EVENT_PAYLOAD_BINDING"
}
},
"type": "MAP_CONTAINER"
},
"params": {
"container": {
"asyncProperties": {
"binding": {
"address": [
"asyncProperties"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"type": {
"binding": {
"address": [
"type"
]
},
"type": "EVENT_PAYLOAD_BINDING"
}
},
"type": "MAP_CONTAINER"
},
"route": {
"type": "JSON_LITERAL",
"value": "mra"
},
"size": {
"type": "JSON_LITERAL",
"value": "lg"
}
},
"type": "MAP_CONTAINER"
}

 

6. Create a new related list action "Remove" to Remove Child RITMs

Shruti_0-1753245454821.png

 

7.  

Shruti_1-1753245498970.png

 

 

 

 

I have done all the steps above. Now the Add button is visible  but it’s not clickable and no records are showing.
Please help me fix it.

Can you please share screenshots related list, action payload and event mapping screenshots?

 

Can you try to update the action payload 

{
"label": "Add",
"userGivenTable": "sc_req_item",
"table": "{{table}}",
"parentRecordSysId": "{{parentRecordSysId}}",
"parentFieldName": "parent",
"referencedFieldName": "parent",
"extensionPoint": "",
"query":"parent=NULL",
"view": "Default",
"columns": "number,short_description",
"type": "o2m",
"hideSelectAll": false,
"relatedListName": "{{relatedListName}}",
"asyncProperties": {
"enableAsync": true,
"asyncThreshold": 50,
"relatedListLabelName": "{{label}}"
}
}