How do I get a List Banner UI Action to not require selecting an item?

bcronrath
Kilo Guru

I am trying to figure out how I can have a List Banner Button not require a selection when clicked.   What I want is a "normalize" style button that basically creates a record for the table in question and gives it certain default values without needing any additional input from the user.

The server side script is simple and shouldn't require a thing from the user or any selected item, it just uses glideRecord to create the record and should finish on its own.   I'm almost there but the only problem is currently no matter what I try, when I click the button from the List view it says "No records selected" in a popup, and forces me to have to select at least one record.   If I select a record and click the button it works as expected (using no info from whatever item is selected of course) and creates the new entry.   The default "New" UI action does not require this at all, but when I check that UI action I can't see any specific reason why it gets away with not requiring a selected item yet mine requires one.

Is there something additional I need to do in order to have a List Banner Button level UI action that does not require selection of items when being pressed?

Best regards,

Brian

1 ACCEPTED SOLUTION

Just a quick update - I found that it seems to be an issue that can be resolved by naming the action name the prefix "sysverb" and then anything after that.   There must be some hardcoded check to see if sysverb is prefixed in the action name, and if so it will not require selection from the list view.


View solution in original post

8 REPLIES 8

will_smith
Mega Guru

Hi Brian, can we see your script and maybe a screenshot of the UI action? Also, what are you attempting to accomplish with your list banner button?


server_clear_portal_fromList();






function server_clear_portal_fromList(){


  action.setNoPop(true);


  var url = current.view.toString();


  action.setRedirectURL(url);



  var gr = new GlideRecord('u_portal_status');


  gr.addQuery('u_selected','true');


  gr.query();


  while(gr.next()){


  gr.u_selected='false';


  gr.update();


  //gs.log("updating " + gr.u_number);


  }



  var defaultBlock = new GlideRecord('u_portal_status');


  defaultBlock.addQuery('u_default_block', 'true');


  defaultBlock.query();



  if(defaultBlock.next())


  {


  defaultBlock.u_selected = true;


  defaultBlock.u_status = "text text text";


  defaultBlock.update();


  }



}



find_real_file.png



Removed the status text but essentially it's just a paragraph of a normalized status message.   Everything works aside from I need to not have a requirement for selecting an item in the list view when pressing this button.   It should just run without any input required other than simply clicking the button.


Now I'm starting to wonder if there is some weird thing where it only does this when a match is made to a hardcoded action name.   If I change the Action name to sysverb_new on my UI Action, it hides the default "New" button, but actually accomplishes what I am looking to do in that it runs my script without requiring me to select anything from the list.



This doesn't really work though since I do still need the "New" button so that new entries can be made.   Anyone know if any ways around this?


will_smith
Mega Guru

When you described this at first, I thought it sounded like something that is hard coded into ServiceNow. Sorry i couldn't be more helpful.