We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Open Category in the ServiceCatalog through UI Action in CSM Workspace

Ruihster
Tera Contributor

Hi All.

I wanted to make the "Create Request" UI Action for CSM Workspace.

I found out about the "g_service_catalog" API but in the Documentation here is only one Function defined.

I was able to open the Service Catalog with the function "openCatalogItem", like the function name says it's for opening a Catalog Item and not a Service Catalog. 

In the UI Action I use:

 

g_service_catalog.openCatalogItem('sc_cat_item', '-1', params);

 

as Param is the Parent Table and Parent Sys_ID.

 

Now the Code opens the whole Service Catalog but now I want that only a specific Catalog Category is opened to show the Catalog Items inside that Category.

 

Is this possible somehow or not and does someone know if there is a Documentation of all functions of that API ?

 

Thanks 

Regards.

12 REPLIES 12

Not applicable

@Ruihster @ChrisJohnsten 

Hi All,
The moto is  open a portal, and for a specific catalog need to submit the request.

 

Please find my Ui action details and code below:

UI action name: Create ICMS Ticket

Active: true

client: true

Onclick: onClickIcms()();

Workspace Form button: true

HemantAggarwal_0-1726748873094.png

 

 


Workspace Client Script//I have wrote the script here as I was not able to execute in on workspace when written in Script section too

function onClickIcms() {
var url = "/" + "sp?id=sc_category&sys_id=354d31471b774a9058b4744a9b4bcbaf&catalog_id=2d8cb1071b774a9058b4744a9b4bcb19&spa=1";
gsftSubmit(null, g_form.getFormElement(), 'create_icms_ticket');
top.window.open(url, '_blank');
}
if (typeof window == 'undefined') case_map();

function case_map() {
var getCase = current.sys_id;
var session = gs.getSession();
session.putClientData('caseID', getCase);
action.setRedirectURL(current);
}

Kindly suggest on how can we get this working.

 

Thanks in advance.


 

Not applicable
function onClick(g_form) {
//  var result = g_form.submit('sysverb_ws_save');
//  if (!result) {
//      return;
//  }
//  result.then(function() {
//      var params = {};
//          params.catalog_id = "2d8cb1071b774a9058b4744a9b4bcb19&id=sc_category&sys_id=354d31471b774a9058b4744a9b4bcbaf";
//      g_service_catalog.openCatalogItem('sc_cat_item', '-1', params);
//  });
}

stefankuehnel
Tera Contributor

If you want to make it work in the Service Operations Workspace (SOW) as well, you can use the following script:

function onClick() {
	var result = g_form.submit('sysverb_ws_save');
	if (!result) {
		//failed form submission
		return;
	}
	
	result.then(function() {
		var params ={};
		params.sysparm_parent_table = "incident";
		params.sysparm_parent_sys_id = g_form.getUniqueValue();

		params.category_id = "2c0b59874f7b4200086eeed18110c71f";

		g_service_catalog.openCatalogItem('sc_cat_item', '-1', params);
	});
}

 

Tested today on a Personal Developer Instance with the following specs:

Build name: Xanadu
Build date: 06-04-2025_0434
Build tag: glide-xanadu-07-02-2024__patch9-05-21-2025