Custom list view action requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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.