Passing values from Interaction to Service Catalog

menardJA
Tera Contributor

I am currently working with my Service Desk team to make their workflows more intuitive and document information such as phone number and location before they get to the Incident or Request form. I have added these as available fields on the Interaction form where they start all their calls from within Service Operations Workspace.

 

What I am struggling with is the UI Action for Create Request and how to include the phone number and location data from the interaction to the Service Catalog form similar to how the Name populated in Opened For already carries over.

 

Any insight would be appreciated.

8 REPLIES 8

Shivalika
Mega Sage

Hello @menardJA 

 

You can just copy the configurations we have for "create Incident UI Action" in WOrkspace client script in "Create Request" UI Action. You can take reference. It should be same way for request as well. 

 

Shivalika_0-1743924465205.png

 

 

Create request UI Action - https://<<instance-name>>.service-now.com/sys_ui_action.do?sys_id=4df66aa187e41300e3010cf888cb0b6b&s...

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

 

I tried this and the phone number and location data that is being captured in the interaction is not being pulled into the Catalog Item when a request is being generated from an interaction.

Hi @Shivalika 

This is what I have for scripts in the Create Request UI Action however it is still not working.

var canCreateRequest = false;
if ((current.isNewRecord() && current.canCreate()) || (!current.isNewRecord() && current.canWrite()))
	canCreateRequest = current.update();
else
	canCreateRequest = true;

if (canCreateRequest) {
	var req = new GlideRecord("request");
	req.initialize();
	req.phone_number = current.u_phone_number;
	req.u_extension = current.u_extension;
	req.location = current.location;
	if (GlidePluginManager.isActive("sn_itsm_gen_ai") && current.chat_summary && (current.chat_summary.toString()).length < 4000) {
		req.description = current.chat_summary;
	}
	req.origin_table = "interaction";
	req.origin_id = current.sys_id;
	if (gs.getProperty("com.snc.req.create_from_interaction.save") === 'true') {
		req.work_notes = gs.getMessage('Request created from Interaction {0}', current.number);
		var reqSysId = req.insert();
		if (reqSysId) {
			var interactionRelatedGR = new GlideRecord("interaction_related_record");
			interactionRelatedGR.initialize();
			interactionRelatedGR.interaction = current.sys_id;
			interactionRelatedGR.document_table = 'request';
			interactionRelatedGR.document_id = reqSysId;
			interactionRelatedGR.insert();
		}
	}
	action.openGlideRecord(req);
	new InteractionRelationshipUtil().copyAttachments(current, req);
}
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 = "interaction";
		params.sysparm_parent_sys_id = g_form.getUniqueValue();
		g_service_catalog.openCatalogItem('sc_cat_item', '-1', params);
	});
}

  

Hello @menardJA 

 

The condition at the beginning itself is incorrect - how can ((current.isNewRecord() && current.canCreate()) || (!current.isNewRecord() && current.canWrite()))

 

These two things co-exist ? 

 

And I don't think you should be initializing the request form - because request is not created like that - you need to create a cart and then add catalog item in it and then request is generated. 

 

Request is different from every other table. That's the reason the original request used g_service_catalog. 

 

Let the original code be, just add few lines there of your requirement otherwise it won't work at all. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY