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

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

Anil Lande
Kilo Patron

Hi,

The code looks good to me. Can you please put some Info logs into the server side script include function.

Check where it is failing, also add an extra else (4th ) to return some random value like 'no_output'.

We have observed such behaviors in our custom application where end user does not return anything when we use glide record queries (because of ITIL role restrictions). 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Anurag Tripathi
Mega Patron
Mega Patron

Please add a log on your script include on line 8

gs.log('row count = '+user_list.getRowCount())

Check the logs later to see what are you getting exactly.

 

And yes on the Client Script make the following correction:

its not sysparam

its sysparm 

so replace that.

-Anurag

Yes, it is working. But the row count is showing crazy numbers when there are no assets tagged to the user. How can I correct that?