The CreatorCon Call for Content is officially open! Get started here.

Script include returning null

Kevin Paul
Mega Guru

Hi,

I have a script include here where I get all the asset records of the logged in user and based on the no of records returned, I return some value to the client script. The client script uses the value to populate the variable of the catalog item. But, whatever the value returned from the script include is showing as null and the variable is not populating. Can You tell me what is wrong? I have attached the script

find_real_file.png

 

find_real_file.png

 

find_real_file.png

 
1 ACCEPTED SOLUTION

Sourav16
Kilo Guru

Hi Kevin please try this code below replace sysparam with sysparm :-

ga.addParam('sysparm_name' , 'GetAssignedAsset');
ga.addParam('sysparm_user' , g_user.userID);

 

Also  I  would recommend to use GlideAggregate API for counting records instead of GlideRecord ( gr.getRowCount())

 

GlideAggregate -API

View solution in original post

8 REPLIES 8

While reading also , in your script include you should change it form 

 this.getParameter('sysparam_user')

to

 this.getParameter('sysparam_user')

 

Also try the below to convert it to string

 this.getParameter('sysparam_user').toString()

-Anurag

updated it. Thank you

All should be fine now.

If the question is answered please close the thread by marking my(or any other's) answers helpful/correct.

-Anurag

-Anurag

The SN Nerd
Giga Sage
Giga Sage

Hey,

It is Best Practice to use GlideAggregate for counting records.

"Use GlideAggregate for Simple Record Counting"

https://developer.servicenow.com/dev.do#!/guides/paris/now-platform/tpb-guide/scripting_technical_be...

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideAggregateAPI?na...

 

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022