List View UI action not working

Linda6
Mega Guru

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:

infoemail.png

 

 

 

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?

3 REPLIES 3

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..

Bert_c1
Kilo Patron

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.