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

Community Alums
Not applicable

hI @pavan_yadav ,

 

Can you share screenshot of your script?

Hi @Community Alums 

 

pavan_yadav_0-1752660964931.png


the above is sysauto_report  table condition field script and 
below is sys_properties table record

pavan_yadav_1-1752661055162.png

when i check logs
im getting --> 

pavan_yadav_2-1752661183791.png


in background script im able to see sys id of created property.

pavan_yadav_3-1752661233437.png

 

@pavan_yadav I got it!!!!

 

It is because you are entering the script to Condition field 😉

And it doesn't make sense for condition. 

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


@pavan_yadav 

Try anything similar to:
(just a draft, not tested)

var prop = gs.getProperty('some.property.name'); 
if(prop = 'Source') {
return true;
} else {
return false;
}

 

 

*prop return sys id so the if condition the script shall be per sys_id not name...

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


Hello @GlideFather ,
But in the condition we can write script some ootb script screen shot below,
condition is a script field, so for the below script it is working.

pavan_yadav_0-1752661929999.png

 

And also i have tried like below:

pavan_yadav_1-1752662124529.png


im getting result but to avoid hardcoding I want to use properties here.