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

That is fine, but you got "undefined" because your scripted condition was:

var prop = gs.getProperty('com.glide.cs.branding.support_email_label');
gs.info(prop);

 

please add there some values to return and let me know how did it go.

 

Try something like this:

var prop = gs.getProperty('some.property.name'); 
//perhaps it must be prop = sys_id of the property
if(prop = 'Source') {
gs.info('Out if Prop true');
return true;
} else {
gs.info('Out if Prop false');
return false;
}
———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Yes I checked

var prop = gs.getProperty('com.glide.cs.branding.support_email_label');
gs.info('Pavan' + prop);
--> com.glide.cs.branding.support_email_label  : Send Email to Customer Support
same result, 
pavan_yadav_1-1752663071275.png

If you have time just write your script or my script in that condition field and click on execute now button and check logs you will also get undefined.

 

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

Hello, @Ankur Bawiskar ,
how to override this, I just want to write condition script only for one record, and to avoid hardcoding I chosen this.
For one record, I can not create script include.
i seen your reply in one of post:
Solved: Get property value in Report filter condition - ServiceNow Community

in that he is calling script include for multiple records, but in my case, for just one record only.
could you please confirm that why condition field is not behaving normally, is there any reason if yes how to override that.

 

@pavan_yadav 

Please try with script include and then use gs.getProperty() schedule that report every 15mins to see if log came

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