Returning a string, object or an array from script include gives value undefined

moni170
Tera Contributor

I created an onchange Client Script on Configuration item field of incident table. Used GlideAjax and Script-Include.

The script include returns the company, manufacturer and the asset_tag value of the configuration item being selected.

But somehow it's returning undefined.

I tried using array, object and string as well to return the value from the script include but still the same result.

I even tried to match the sys_id instead of the name field.

I'm attatching the screenshots of Client script, script include and the output here.

Looking forward for the solution.

Thankyou.

2 ACCEPTED SOLUTIONS

Sandeep Rajput
Tera Patron
Tera Patron

@moni170 Here is the source of your issue.

 

someCode.jpg

Please try updating your code as follows and see if it works for you.

 

 

cmdb: function() {
	var obj = ‘’;
	var ab = this.getParameter(‘sysparm_ci’);
	var gr = new GlideRecord(‘cmdb_ci’);
	gr.addQuery(‘sys_id’, ab);
	gr.query();
	if (gr.next()) {
		obj = obj + gr.manufacturer.toString() + ',' + gr.company.toString() + ',' + gr.asset_tag.toString();
	}

	return obj;
}

 

Hope this helps.

View solution in original post

Sohithanjan G
Kilo Sage
Kilo Sage

Hey @moni170 , 

you are missing .next() in script include. Please correct it

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)

View solution in original post

5 REPLIES 5

Sohithanjan G
Kilo Sage
Kilo Sage

Hey @moni170 , 

you are missing .next() in script include. Please correct it

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)