Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use Template Value as table column

davilu
Mega Sage

Hi Everyone,

Our team came across a table in ServiceNow Share that had a column with type Template Value, which allows a user to choose different columns from a given table:

find_real_file.png

When we tried to replicate this, we get an Invalid Reference error:

find_real_file.png

Can someone provide some guidance on how to create a field type like this?  

6 REPLIES 6

Hi Arjun,

Are you still looking for a solution to above?


If yes then please follow the steps below

1. Go to Field Class[sys_glide_object] table by typing sys_glide_object.LIST in the navigator.

2. In the list, filter using "Label contains template" and check if the visible value of the "template value" record is "false", as show below

find_real_file.png

3. If yes, then use the below background script to set it to visible

var glideObjGR = new GlideRecord("sys_glide_object");

//4ab89802c611229b0150036cde2dd741 --> sys_id of the "template value" record on sys_glide_object table.

if(glideObjGR.get("sys_id", "4ab89802c611229b0150036cde2dd741")){
	glideObjGR.autoSysFields(false);
	glideObjGR.setWorkflow(false);
	glideObjGR.visible = true;
	glideObjGR.update();
}

 4. Once executed, you can see the "Template Value" field type available to use in Dictionary

find_real_file.png

Once you have created your field using the "Type", do remember to set the "Template Value" visible back to "false" as done below. 

var glideObjGR = new GlideRecord("sys_glide_object");

//4ab89802c611229b0150036cde2dd741 --> sys_id of the "template value" record on sys_glide_object table.

if(glideObjGR.get("sys_id", "4ab89802c611229b0150036cde2dd741")){
	glideObjGR.autoSysFields(false);
	glideObjGR.setWorkflow(false);
	glideObjGR.visible = false;
	glideObjGR.update();
}

 

Thanks & Regards,
Rupam

This is great stuff, Rupam.