List UI Action to open confirm window and update records

Alfred Brorsson
Tera Contributor

Hi all,

I need your help for a small thing that seems to be harder than expected. In our instance we have list UI Actions (Actions on selected rows) to Reject and Approve time cards. I just got the requirement to implement confirm windows for these actions, so that someone doesn't reject or approve multiple time cards by accident. So at first I thought I could do a server/client UI action script as I have before, using  `gsftSubmit(null, g_form.getFormElement(), 'action_name');`. What I came to realize was that `g_form.getFormElement()` doesn't work on a list, and therefore I can't use this. So then I thought I could use a script include, and simply run the server side code there and only have the confirm in the UI Action to call the script include, but then I need to pass the sys_id of the selected records from the UI Action client script and I have no idea if that's possible either.

So basically what I need is a list UI Action that opens a confirm window, and then updates the selected records if the confirm evaluates to true. Is this possible?

Sorry for the long description..

Thanks in advance!!

1 ACCEPTED SOLUTION

Raju Koyagura
Tera Guru

You can try something below...

 

function rejectRecords() {
tblName = g_list.getTableName(); //To get the table name
selSysIds = g_list.getChecked(); //To get the list of selected records sys_id
sysIdList = selSysIds.split(',');
numSel = sysIdList.length;

if(numSel > 0) {
indx = 0;
ajaxHelper = new GlideAjax('RejectRecordAjax');
//
}
}

View solution in original post

3 REPLIES 3

Allen Andreas
Administrator
Administrator

Hi,

I'll look and see what I can find, but I would take a look at the Delete UI action, as that pops up a confirmation window.

So you can tweak that to your liking and just use that for the same UI action that's already there.

I'd take a look at this link too: https://community.servicenow.com/community?id=community_question&sys_id=73638b25dbd8dbc01dcaf3231f96...


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Raju Koyagura
Tera Guru

You can try something below...

 

function rejectRecords() {
tblName = g_list.getTableName(); //To get the table name
selSysIds = g_list.getChecked(); //To get the list of selected records sys_id
sysIdList = selSysIds.split(',');
numSel = sysIdList.length;

if(numSel > 0) {
indx = 0;
ajaxHelper = new GlideAjax('RejectRecordAjax');
//
}
}

Thank you 🙂 This worked