When many-to-many (m2m) related lists such as Requested Items or Remediation Tasks are added to a Change Request record in Service Operations Workspace (SOW), you’ll notice there are no “Add” or “Remove” buttons available out of the box.
These must be manually configured using Now Experience Declarative Actions.

This article focuses on creating the Remove action specifically for m2m related lists.


1. Understand the M2M Relationship

Each related list on the Change Request record (for example, Requested Items or Remediation Tasks) is based on an m2m table:

Related ListM2M TableDescription
Requested Itemssn_vul_m2m_vg_change_requestLinks Requested Items to Change Requests
Remediation Taskssn_vul_m2m_vul_change_requestLinks Remediation Tasks to Change Requests

When you create the Remove declarative action, make sure the Table field targets the m2m table, not the primary table like sn_vul_vulnerability.


2. Create the Declarative Action Record

Navigate to:

Now Experience Framework → Declarative Actions → Related List Actions

Create a new record with the following configuration:

FieldValue
Action labelRemove ({{count}})
Action nameremove
Implemented asServer Script
Button typeSecondary
Record Selection Required✓ Checked
Active✓ Checked
Tablesn_vul_m2m_vul_change_request (for Remediation Task M2M)
ViewService Operations Workspace

💡 You can duplicate this setup for other M2M tables such as sn_vul_m2m_vg_change_request if you need similar functionality.


3. Add the Server Script

Use the following server script to remove the selected M2M relationship record:

if (current.deleteRecord()) {
    gs.addInfoMessage(gs.getMessage("Record {0} removed successfully.", [current.getDisplayValue()]));
} else {
    gs.addErrorMessage(gs.getMessage("Unable to remove record {0}.", [current.getDisplayValue()]));
}

This script deletes the selected M2M record and displays a success or error message in the workspace UI.


4. Configure the “Add” Declarative Action (for context)

If you are also setting up the Add action for M2M tables, make sure to configure the Action Assignment, Payload Definition, and UX Add-on Event Mapping records as follows:

Action Assignment

  • Action label: Add
  • Action name: add_vul_to_cr
  • Implemented as: UXF Client Action
  • Specify client action: Add remediation task to change request
  • Table: sn_vul_m2m_vul_change_request
  • View: Service Operations Workspace
  • Active: ✓ Checked

Action Payload Definition

Example payload for Add remediation task to change request:

{
  "label": "translate('Add')",
  "userGivenTable": "sn_vul_vulnerability",
  "table": "{{table}}",
  "parentRecordSysId": "{{parentRecordSysId}}",
  "parentFieldName": "change_request",
  "referencedFieldName": "sn_vul_vulnerability",
  "extensionPoint": "DEFAULT",
  "view": "Default",
  "columns": "",
  "type": "m2m",
  "hideSelectAll": false,
  "relatedListName": "{{relatedListName}}"
}

UX Add-on Event Mapping

  • Source Component: Related Records
  • Source Declarative Action: add_vul_to_cr
  • Controller: Form
  • Target Event: [Record Page] Open modal

Example Target Payload Mapping (partial):

{
    "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": {
                "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"
}

5. Validate in Service Operations Workspace

  1. Open a Change Request record in SOW.
  2. Navigate to Related Records → Remediation Tasks (or another M2M list).
  3. You should now see Add and Remove buttons above the related list.
  4. Use Add to link new tasks, and Remove to unlink existing ones.

🧠 Remember to Clear Cache

After creating or modifying Declarative Actions or UX mappings, run the following in your instance to refresh the UI cache:

cache.do

Then refresh your browser.


✅ Summary

By configuring Add and Remove Declarative Actions for M2M related lists, users can manage relationships like Remediation Tasks and Requested Items directly in the Service Operations Workspace, streamlining change management processes and improving usability.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *