Unable to retrieve property value using gs.getProperty('') in scheduled report (sysauto_report)

pavan_yadav
Tera Contributor

I'm trying to use var prop = gs.getProperty('some.property.name'); inside a scheduled report (sysauto_report), but the value of prop keeps returning undefined. Can anyone confirm if gs.getProperty() works in scheduled reports, or if there's a limitation in that context?

 

Thanks,
Pavan.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@pavan_yadav 

I believe it has something to do with the sandboxing.

Check this link which talks the same which all classes are not allowed

Script sandbox property

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

31 REPLIES 31

GlideFather
Tera Patron

@pavan_yadav 
check it in background script, what it returns when you call that property or you can log it..


I just tried to call a random property and that work, try it in you instance, similarly to:

KamilT_0-1752657836116.png

 

And if it returns ok, then you know it is something with the scheduled report. Couldn't it be due to cross-scope?

 

EDIT:

in the script above I called this property:

KamilT_1-1752657909073.png

 

 

And I noticed following:

  • is the "read role", does your report have right to read the system property?? 
  • isn't the property marked as Private?
———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Hi @GlideFather ,
In background script or other places, I'm able to retrieve property value but in the sysauto_report table we have condition (script) field there if I try to retrieve property value it is giving me undefined.

Can you provide screenshot of your script and system property

If my response was helpful, please mark it as correct and helpful.
Thank you.

@pavan_yadav can you please check the scope of your property?
And how did you add a script to sysauto_report? Is the report in the same scope as the property?

 

if you property is named "my_property" and scope is "x_snc_scope", then call it:

x_snc_scope.my_property

 

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


@pavan_yadav I was asking here where did you manage to get a script for sysauto_report as there is no script field. 

 

The only one is Condition, so you need to return the result for the Condition:

KamilT_0-1752661758393.png

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */