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

Custom list view action requirement.

HrishabhKumar
Kilo Sage

I have this following requirement:

1) In cmdb_ci_business_app tables list view, if anyone selects on or more than one records in the list view and clicks on "Trigger App Criticality&Risk Asmt" ui action from the list choice. I need the following.

1) get sys_ids of all the selected records.

2) Add an info message showing total number of records which were selected.

 

I have created a UI action (client side), to perform this activity. How can I access the sys_ids and add and info message.

 

Screenshot 2025-08-25 at 8.41.40 PM.png

6 REPLIES 6

RaghavSh
Kilo Patron

Try below:

 

var Ids = g_list.getChecked();

var selectedIds = Ids.split(',');

g_form.addInfoMessage("sys_ids are " +Ids);
g_form.addInfoMessage("Length is " +selectedIds.length);

 

You can combine the info messages as per your need.


Raghav
MVP 2023
LinkedIn

Hi @RaghavSh , you can not access g_form in UI action.

Hi @HrishabhKumar 
try this code in bg-script

 

(function executeListAction() {
    var selectedRecords = GlideListAction.getSelectedRecords(); 
    if (!selectedRecords || selectedRecords.length === 0) {
        gs.addInfoMessage("No records selected.");
        return;
    }
    var sysIds = [];
    selectedRecords.forEach(function (rec) {
        if (rec.sys_id) {
            sysIds.push(rec.sys_id);
        }
    });
    gs.info("Trigger App Criticality&Risk Asmt started for sys_ids: " + sysIds.join(","));
})();

 

Best regards,
Ankit B

If this solution worked for you, kindly mark it as Accepted Solution and give it a Helpful rating to support the community.

@ankitbanerj I used g_list not g_form and it works perfectly well in UI action (client side).

True , g_form will not show message it has to be through alert or UI page

Please verify the script in your PDI.


Raghav
MVP 2023
LinkedIn

Not working! @ankitbanerj 

I've tried this script

function showSelectedSysIds() {
    alert('check 1');
    var selectedRecords = GlideListAction.getSelectedRecords();
    alert('selectedRecords: ' + selectedRecords.length);
}

 

When i click on the ui action button:

1) I can see the first alert popping. i.e. check 1

2) But after that nothing happens.