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.

GlideRecord not working on ui page

Rj27
Mega Guru

Hi,
In my ui page, I have my HTML script as:

<g:evaluate var="jvar_productSysId" expression="RP.getWindowProperties().get('sysparm_product_sys_id')" />

 

<g2:evaluate object="true">

var productType = new GlideRecord("cmdb_ci_business_app");

productType.addQuery("sys_id", $[jvar_productSysId]);

productType.query();

if(productType.next()){
 var productFamily = productType.apm_application_family; 

</g2:evaluate>

<input type="hidden" id="productFamilyValue" name="productFamilyValue" value="${productFamily}"></input>

 

and in client script i am trying to get alert:

alert(gel('productFamilyValue').value);

But this is not working.
How can i use this value in client script ?
Also, this variable 'productFamily' should give sys id . I want display value as well.



1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update as this to get display value

HTML:

<j:set var="jvar_productSysId" value="${JS:RP.getWindowProperties().get('sysparm_product_sys_id')}" />

	<g:evaluate object="true" jelly="true">
		var productFamily;
		var productType = new GlideRecord("cmdb_ci_business_app");
		productType.addQuery("sys_id", jelly.jvar_productSysId);
		productType.query();
		if(productType.next()){
		productFamily = productType.apm_application_family.getDisplayValue(); 
		productFamily;
		</g2:evaluate>

	<input type="hidden" id="productFamilyValue" name="productFamilyValue" value="${productFamily}"></input>

Regards
ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Hi Ankur,

This (quotes) was a typo while adding the reply.
The actual issue was with the value that was selected.
I have marked your answer correct .
Thank you!

@Rj27 

Glad to know.

Please mark appropriate responses helpful as well.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader