The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Workspace, add a List button that will process Selected records

poyntzj
Kilo Sage

I need to add a new button to a list/related list in the Software Asset workspace, but any configurable workspace will do.

The button needs to be visible (either all the time, or only when records are selected) and will process only the selected records calling a client script or preferaby a Script Include.

The button does not need to load a modular page, a new list in a new tab, allow me to assign the records to myself - there are a number of examples of those around, but I am afraid they have not helped me in my scenario.

I have read all sorts of links and seen a number of videos that do not help my requirement, one said it needs a "few steps", and then proceeds to show 9 tables that maybe impacted !

 

How do I achieve the "select a few records and pass those ID's onto a Script Include"  ? 

 

Before

Classic - create a UI Action, choose list and add a script

Agent Workspace - as above, choose the Workspace options and a new script.

 

UI Builder - this is not intuititive at all.  To make it worse, I start to follow some of the links I found, then find it does not work and at the bottom there are "this is not working in Tokyo, Utah, Vancouver", so now I read the link, all the comments and check to see if there is a "not working in....".

Indeed, some of the UI Builder has changed quite a bit inbetween the Tokyo instance I am working at and the Vancouver PDI I am trying to work this out on.

 

Following one of the videos (cheers Brad), I added an Event Handler, I saw it look OK in the page in another tab, then back into UI builder it was not there - no idea where it vanished to. Thinking I had done something wrong, I went to create again (which it allowed), and then when I checked the workspace I was told I had 2 handlers with the same name..... yes, I recreated as it was missing, but then when I went back into the UI Builder neither were there.

At this point I backed that out and decided to go and do all this work/testing in a PDI

 

Any guidance would be appreciated - even if it is how to get a button on a list/related list and just pass the ID's to a Script Include that will simply add them to the log.

 

Thanks in advance

6 REPLIES 6

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @poyntzj 

Please check below link

https://www.servicenow.com/community/next-experience-articles/how-to-use-ui-actions-in-workspaces/ta...

In above docs it had given brief idea about how to use Ui action and create new ui action in workspace as well as other important things also.

Please check and Mark helpful if it will helps you.

poyntzj
Kilo Sage

So, right now, the way I have done this is on the Action Assignment is to change the "Implemented as" to being "Client Script", which unlocks the client script options and I can then use g_form.getClicked() and go off and do an ajax call.

The thing is, the buttons I have "copied" are doing a UXF Action - whatever that well means. 

None of what I have seen here is pretty, intuiative, and typical SNC documentation and learning = useless.

Not helping that the documents, blogs, video's generated by the other kind citizens here and on the net are seemingly out of date each release. 😞 - though please do keep creating the blogs and videos as while they have not helped in my case, they do open ones eyes and provide ideas.

 

We are trying to get time with someone from SNC to sit with a few of us who have had "issues" with this Now experience and for them to go through our actual requirements from scratch and not doing the usual SNC sales or pre worked blurb, but to come join and go through our requirements so we can see where we are all going wrong and what their best practice is (we do not think that some of what we have done meets that criteria, but it works and that is more important for us right now). 

So far, they have not found anyone to do this.......

Bex
Tera Contributor

Hi, we are looking for a similar solution, could you share your code/how you achieved this? we are also struggling to work with Now experience and looking for SNC to support us on best practice, did you manage to get anyone?  

My solution was similar to yours:
create Action Assignment <Implemented as>  "Client Script". (aka UI action For work spaces)
(https://www.youtube.com/watch?v=lTDa8nFRvmU)
and use script :

 

 

function onClick() {
var sysIds = g_list.getChecked().split(",");
console.log(sysIds);

var prompt = "amount of selected records  " + sysIds.length;

g_modal.confirm(prompt, function(confirmed) {
	if (confirmed) {
		// calL AJAX
		console.log("User confirmed: Yes");
	} else {
		console.log("User declined: No");
	}
});
}