Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

keithl22
ServiceNow Employee

This will be a short, simple, and hopefully useful article on how to create a shortcut to a record producer or catalog item on the Agent workspace so that fulfillers can access it quickly for frequently used requests. For this demo I will walk through adding the OOTB “Report Outage” Catalog Item to the list view on the HR Agent Workspace so HR Agents can quickly report an outage on one of their applications.

 

  1. Start by making sure you are in the right scope for whichever workspace you are usingfind_real_file.png
  2. You’ll also need to grab the system ID of the Record Producer you want to add to the Workspacefind_real_file.png
  3. Next you will navigate to the List Action menu for the Workspacefind_real_file.png
  4. Click “Create New”find_real_file.png
  5. Fill out the following:
    1. Action Label – This will be the display value for the button that will be created
    2. Action Name - internal name for the List Action
    3. Implemented As – Set this to Client Action
    4. Button Type – Primary
    5. Workspace – Set it to the Workspace where you want to add the button
    6. Table – Any workspace list views for this table will have this button available.
  6. Here is what your form should look like at this point.find_real_file.png
  7. Next we need to add a Client Action
  8. Click the look up icon in the “Specify client action” field
  9. Create a New Action Payload Definition when the new window opens.find_real_file.png
  10. Fill out as follows:
    1. Key = ITEM_SELECTED
    2. Label = Same as Action Label from 5a. (Mainly for recordkeeping and easier maintenance, you can really call it anything)
    3. Applicable To = List
    4. Payload = {"table":"sc_cat_item","row":{"sys_id":{"value":"<sys_id of Record Producer>"}},"parent_table":"{{parentTable}}","additional_data":{"query":"{{query}}"}}
    5. Description = Added for additional context
  11. Your form should look like this.find_real_file.png
  12. Click Submit
  13. You’ll be directed back to the Action record you created earlierfind_real_file.png
  14. Save the Action
  15. After saving the You will see the new list action on the workspace list you specified.find_real_file.png

 find_real_file.png

 

That’s all there is to it! Hope this was useful.

Comments
Vaishnavi Mamad
Tera Explorer

This is not working, the button is not showing up when followed the same steps, any help appreciated

learn nv
Tera Contributor

Hi keithl22

I followed the suggested steps, but when I clicked on the button, record producer is not getting opened.

When I check the console, I could see this error 'the resource was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally'. Used  Client Action 'Create Catalog Item' is OOB one.

 

Any suggestions?

list button.JPG

CharlesGriff
Mega Sage

This is not working in Yokohama is this solution still relevant on the new versions?

Brad Bowman
Mega Patron

@keithl22 is there an updated payload or something else that needs to be done to get this to work in Yokohama with a UXF Client Action?  I'm trying to open a Record Producer from a button on the Project Workspace.  Following the above I can see a button, but it doesn't do anything.

BradBowman_0-1770210830845.png

BradBowman_1-1770210877613.png

 

Bushra Aneeqa
Tera Contributor

the button is visible but it doesn not redirect to the record producer

Brad Bowman
Mega Patron

I found a workaround to this approach that works in Yokohama.  Create a UI Action instead of a Declarative Action.  I guess I assumed from this post that UI Actions no longer worked in workspaces, replaced by Declarative Actions, but it seems to be more like Declarative Actions are supplementing UI Actions.  Overall the transition to configuring workspaces is monumentally more difficult than it needs to be due to the schizophrenic nature of the cobbled-together architecture, and the lack of helpful documentation and posts that actually work several versions later.

 

In any event, my example is on the Project Workspace, but I would think the same approach might (?) work elsewhere. I can't seem to post screenshots anymore, but the UI Action is in the Global scope, empty except for the Name, table, active, Show update, Client, and List v2 Compatible.  Check Form link if you want this to appear in a menu in the workspace, and on the Workspace tab, check Workspace Form Menu and Format for Configurable Workspace.  If you want a button instead, leave Form link unchecked, and on the Workspace tab check Workspace Form Button instead.

 

Here is my script, which launches the Catalog Item in a separate browser tab - basically just give it the URL of launching the item manually.  In my case I'm also adding a parameter to populate a variable with the current project.

 

function onClick(g_form) {
	//var url = 'com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=378b2325c397bad0676a07f9d0013172&sysparm_v_project=' + g_form.getUniqueValue(); //Catalog Item
	var url = 'now/nav/ui/classic/params/target/com.glideapp.servicecatalog_cat_item_guide_view.do%3Fv%3D1%26sysparm_initial%3Dtrue%26sysparm_guide%3D988fc596c35f3e14676a07f9d001312d&sysparm_v_project=' + g_form.getUniqueValue(); //Order Guide
	open(url); 
}

As the comments suggest, the first version was working for a Catalog Item, then I switched to an Order Guide, which is the second url value.

 

To populate the variable on the Catalog Item from the url parameter you need a script like this:

function onLoad() {
	//Populate the variables with the parameters passed in the URL
	//Use the 'getParmVal' function below to get the parameter values from the URL
	//UI Action passes in project in sysparm_v_project
	var project = getParmVal('sysparm_v_project');
		
	function getParmVal(name){
		var url = document.URL.parseQuery();
		if(url[name]){
			return decodeURI(url[name]);
		}
		else{
			return;
		}
	}   
	g_form.setValue('v_project', project);
}

 

Version history
Last update:
‎12-10-2021 09:04 AM
Updated by: