The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Declarative action in related list to show a page as pop up

Stenali
Kilo Contributor

Hi Team,

As a part of requirement, I need to have a UI Action at related list level that shows a pop-up with 2 fields. 

1)User Field

2)Comments Field
And a submit and cancel button below those fields. submitting this pop-up will create a new approval record and attach it to the corresponding record on which this related list tab is there.

Stenali_0-1756718078658.png

I am able to achieve it in the native UI, but have trouble delivering the same at workspace level.

I have created a declarative UI Action, and I can see it on the related list of the Approvals.

Stenali_1-1756718345175.png

But that declarative action is not function even after using OOB mapping events and action payload definition. Here are the configurations for the declarative action, please check and let me know where am I going wrong.

1)Declarative Action

Stenali_2-1756718575523.pngStenali_3-1756718597612.png


2)Action Payload

Stenali_4-1756718638465.pngStenali_5-1756718661886.png


3) Mapped Event

Stenali_6-1756718727191.png

Target Payload:
{
"container": {
"fields": {
"binding": {
"address": [
"fields"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"params": {
"binding": {
"address": [
"params"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"route": {
"binding": {
"address": [
"route"
]
},
"type": "EVENT_PAYLOAD_BINDING"
},
"size": {
"binding": {
"address": [
"size"
]
},
"type": "EVENT_PAYLOAD_BINDING"
}
},
"type": "MAP_CONTAINER"
}

 

4) UX Target Event

Stenali_7-1756718831623.png


I have created a new page with the two fields and the buttons, and calling that page in the Action Payload Definition as route.

Stenali_8-1756719001438.png


Let me know if any further details are required to resolve this issue.

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Stenali 

why not do this?

1) implement that declarative action as Client script

2) then use g_model.showFields() to show your fields

3) then handle the logic on click of OK and Cancel

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

Shruti
Mega Sage
Mega Sage

Hi @Stenali 

Did you add event handler on click of Submit button to create approval record?

CharanV98428402
Mega Contributor

To display a popup when the Declarative Action in the related list is clicked (show the page in a popup window)

 

Step - 1: Create a Modal

CharanV98428402_0-1756820526941.png

Click on the + icon and select the “Custom” model. And in the body of the custom modal add any component Example: Textarea

CharanV98428402_1-1756820549298.png

Step 2: Create an event handler in the page body and trigger the "Open or Close Dialog Window" action, which corresponds to the "Custom 1" model.

→ To create a custom event handler, navigate to the Page Body. Then, on the right side of the screen, go to the Events tab as shown in the below picture.

CharanV98428402_2-1756820573086.png

On the Events tab, scroll down to the bottom to find the Handled Events section. In that section, click ADD. A popup will appear where you need to fill in fields such as Event Label and Template.

→ When you enter the Event Label, the Event Name will be auto-populated. Then, in the Payload Fields section, click the Add button and enter a payload name. Once it is done click on the “Add” button on the bottom of that popup.

CharanV98428402_3-1756820592143.png

Step 3:  Add an event mapping to open the modal whenever the event is triggered which we have created in Step 2 is triggered.

CharanV98428402_4-1756820607261.png

As highlighted in the above picture click on the “Add event mapping” button and attach the event we have created in step - 2 to open a model as shown in the below picture.

→ In the below picture “OpenModel” is nothing but the event handler we have created in the step - 2. So select the event you have created and click on the continue button.

CharanV98428402_5-1756820628117.png

Once you click on the continue button you will have another pop up where you have to select the “Open or close modal dialog” and click on continue button.

CharanV98428402_6-1756820645353.png

Once you click on the continue button you will have another pop up where you have to select the model we have created in step -1 and click on add button.

CharanV98428402_7-1756820659471.png

Step - 4: Create a record in “sys_declarative_action_assignment” table.

CharanV98428402_8-1756820675688.png

Set the Implemented as field to “UXF client action” and set the table to the table where you need the button to be displayed. And we have to create a new record in the “sys_declarative_action_payload_definition” table and tag it to the “Specific client action

Step -5: Create Specific client action in “sys_declarative_action_payload_definition” table.

CharanV98428402_9-1756820692460.png

In the “Payload” field the value i gave is nothing but the payload field we have created previously, i have attached the picture below for your reference.

CharanV98428402_10-1756820708420.pngCharanV98428402_11-1756820714204.png

Now we have successfully created a record in “sys_declarative_action_assignment” table.

Step - 6: Create a record in the “sys_ux_addon_event_mapping” table.

On the “sys_declarative_action_assignment” record we have created in the above step scroll down to the related list and under the “UX Add-on Event Mappings” related list we have to create a record.

CharanV98428402_12-1756820731280.png

For “Source element ID” field navigate to the UI builder and click on the related list and copy the id of the related list and paste it in the “Source element ID” field. 

CharanV98428402_13-1756820743996.png

For the “Parent Macroponent” field on the top of the page you will see the “settings” button, which is highlighted in the below screenshot. Click on that and copy the name and set the value of “Parent Macroponent” field.

CharanV98428402_14-1756820759066.png

And finally for the “Target Event” field select the record which we have created in the step -2 and step -3.

And in the “Target Payload Mapping” field copy the payload given below.

{

    "container": {

        "OpenModelWindow": { // Where ever you see OpenModelWindow is nothing but

CharanV98428402_15-1756820770253.png

 

            "binding": {

                "address": [

                    "OpenModelWindow"

                ]

            },

            "type": "EVENT_PAYLOAD_BINDING"

        }

    },

    "type": "MAP_CONTAINER"

}

 

Once all the above steps are done navigate to the Workspace and open any incident related list, here in my case i am testing with the “Child incident related list”

 Output : 

CharanV98428402_16-1756820787390.pngCharanV98428402_17-1756820794360.png

 

Regards,
Charan

Thank you soo much for the detailed instruictions Charan. It's finally working now.