how to hide "No Records selected" alert on click of list button

pavan_yakkala
Kilo Contributor

Hello,

 

I have a requirement like on click of list button from list layout without selecting any record from the list layout, i have to proceed further.

but an alert "No Records Selected" forcing me to select the record.

 

I want to proceed without this alert..it means on click of list button, first record has to selected by default and should proceed further without any alert.

 

Can any one help on this.

 

Thanks in Advance,

Pavan.

16 REPLIES 16

andrew_venables
ServiceNow Employee
ServiceNow Employee

Hi Pavan,



If you make the button a 'Client' button, by ticking the Checkbox then you can add some Client-side javascript to the script wrapped in a function and call it using the OnClick field, you can then also include a server portion aswell. Take a look at this example of Client and Server side mixed together in one UI Action




function clientMyAction() {


        alert('Hello World, i am client-side script!');


        gsftSubmit(null, g_form.getFormElement(), 'my_action');  


}



if (typeof window == 'undefined')


        myAction();



function myAction() {


        gs.log('Hello World, i am server-side script!);


        action.setRedirectURL(current);


}


Thanks Andrew for your reply.



I have gone through this piece of code earlier..it works fine for Form Actions or Form buttons. But in my case, it is for List buttons or List actions where gsftSubmit or g_form.getFormElement() won't work.



can you please guide me any thing available for list buttons or list actions.



Thanks,


Pavan.


Yes these functions will not work on a list.



You can use the same piece of client-side code and then depending on what you are ultimately trying to achieve maybe a GlideDialogWindow and a custom UI Page to perform the server actions you want.



What is it you want actually want to achieve?


I have the same issue.



I have a boolean field, that indicates whether a record has been printed. From time to time, I want to be able to print all records that are not printed yet. Therefore I would like to run server side code, when clicking the list button called "Print". I don't want to select any items, as the script will query them for me. Though, the strange part is that ServiceNow requires us to select items from a list on a Server Side UI Action, while it is not even possible to obtain those selected items, as g_list.getChecked() does not even work server side. So how are we able to click the button, without having to click on a record first?



Edit: Though ugly, I prefixed "sysverb_" to the action name as Michael Ritchie suggested and it worked like a charm. I really feel like SN should rethink their list buttons.