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.

Syntax for referencing variable in addQuery

Robert Simmons
Kilo Expert

I'm trying to figure out the correct syntax for referencing the variable sys_id as the second parameter of the addQuery function.  The sys_id is alphanumeric so it needs to have quotes around it.  Here's what I've got, but it doesn't work.

	<g:evaluate>
		var sys_id = "'" + RP.getParameterValue("sys_id") + "'"; 
		var nav = new GlideRecord("u_step_content"); 
		nav.addQuery("u_parent", sys_id ); 
		nav.query();
	</g:evaluate>
1 ACCEPTED SOLUTION

Yogi3
Kilo Guru

Try this

 

<g:evaluate>

var sys_id = "'" + RP.getParameterValue('sys_id') + "'";

var nav = new GlideRecord('u_step_content');

nav.addQuery('u_parent', sys_id );

nav.query();

</g:evaluate>

View solution in original post

2 REPLIES 2

Yogi3
Kilo Guru

Try this

 

<g:evaluate>

var sys_id = "'" + RP.getParameterValue('sys_id') + "'";

var nav = new GlideRecord('u_step_content');

nav.addQuery('u_parent', sys_id );

nav.query();

</g:evaluate>

Robert Simmons
Kilo Expert

Thanks.  That worked.  I guess I was overthinking it.