Need to call selected records sysids in ui page

suresh kaliappa
Tera Expert

I have a requirement in ServiceNow Workspace list view.

I created a Declarative Action as a list action, and from that action I am opening a UI Page using g_modal.showFrame(). The UI Page is displaying correctly in Workspace.

Inside the UI Page, I have:

  • User reference field

  • Start date field

  • End date field

  • Submit button

Requirement:
When the user clicks the Submit button, the selected list records should be updated with the values entered in the UI Page (delegate user, start date, end date).

Issue:
I am unable to pass the selected record sys_ids from the Declarative Action (Workspace list view) to the UI Page client script. Because of this, my Script Include is not able to identify which records need to be updated.

Current approach:

  • Using g_list.getChecked() in Declarative Action

  • Opening UI Page using g_modal.showFrame()

  • Calling GlideAjax from UI Page submit button

Question:
What is the recommended way in Workspace to pass selected list record sys_ids from Declarative Action to a UI Page / UI Page client script for further processing?

Any guidance or sample approach would be helpful.

1 REPLY 1

pr8172510
Tera Guru

Hi @suresh kaliappa ,

In Workspace Declarative Actions, g_list.getChecked() does not work reliably like classic UI.

The recommended approach is to pass the selected row sys_ids through g_modal.showFrame() URL parameters.

function onClick(g_list) {

var selectedSysIds = g_list.getChecked();

g_modal.showFrame({
title: 'Delegate Records',
url: '/delegate_ui_page.do?sysparm_sys_ids=' + selectedSysIds,
size: 'lg'
});
}

Then inside the UI Page client script:

 

var sysIds = gel('sysparm_sys_ids') ||
new URLSearchParams(window.location.search).get('sysparm_sys_ids');

console.log(sysIds);

 

You can then pass these sys_ids into GlideAjax and update the selected records in your Script Include