List View UI action not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 10:01 AM - edited 06-28-2023 10:01 AM
Hello Community!
I have to create a list choice UI action that works (obviously) on the list view of the table.
There should be a list view action available called 'Info - Mail' which performs the following actions:
- validates pre-requisites for an Info Mail
-> status is New
-> mandatory fields: Assignment Group, Category, Subcategory
-> if one of them are not met, the Ticket is not being changed and an error message appears
For tickets that meet the requirements, the following actions are performed:
-> enter 'Info - Mail' in close notes
-> change status to info (9)
-> set value u_close_info to 'no'
-> set value u_bonus_malus to 'no'
-> set value u_ds_relevant to 'no'
I created this UI action, code is below the image:
function infomail() {
var selectedIds = g_list.getChecked();
for (var i = 0; i < selectedIds.length; i++) {
var gr = new GlideRecord('u_xxxx');
if (gr.get(selectedIds[i])) {
if (gr.state != '1' || gr.assignment_group.nil() || gr.category.nil() || gr.subcategory.nil()) {
gs.addErrorMessage(gs.getMessage('tch.infomail.error')); // Set localized error message
gr.u_close_info = 'no';
gr.u_bonus_malus = 'no';
gr.u_ds_relevant = 'no';
gr.state = '9';
gr.close_notes = 'Info-Mail';
if (gr.changes() && gr.update()) {
action.setRedirectURL(gr);
}
}
}
}
}
When I select some records from the list view and click on the list action, nothing happens with the records, they are not updated... can someone maybe give me an advice, what I am doing wrong here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 11:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 03:57 AM
Hi @Bert_c1
thank you, but how exactly shall that first link help me? I'm only calling the list choice UI action server-side..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 07:27 AM
Hi @Linda6
Try, un-checking "Client" on the UI Action. Look at OOB UI Actions in your instance. The first KB shows a script logic that can be used. Also, the use of "var gr = new GlideRecord([some_table]);" can lead to problems.
Create a Support Case if you like, to have Servicenow support experts help you.