HRSD Reporting with Dynamic references
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 01:35 PM
Hey everyone,
I am trying to write a report using a table that I created in Human Resources: Core. The report requires a dynamic lookup to find out what Organization the current user is in. Organization is basically my company's idea of Division but different, so just roll with it. So on the sys_user table, there exists a u_organization field with a reference to a sn_hr_core_organization table.
In HR Profile there exists a reference to sys_user. So the report is supposed to pull all sn_hr_core_profile records with the user.u_organization reference equal to "my organization". Sounds easy enough.
I created a Dynamic Filter. That filter references the sn_hr_core_organization table. If I put a static sys_id string inside the script field, it works.
Now, I have two script includes. One inside the sn_hr_core namespace called OrganizationUtil and another in the global namespace called HRReportUtil. I have tested both scripts independently and they are both valid, no errors.
However, if I try to use either one of them in the dynamic filter, in the report, I am getting...
// When the Dynamic Filter script is set to "new sn_hr_core.BilletUtil().getMyOrganization();"
Evaluator.evaluateString() problem: java.lang.SecurityException: Illegal access to private script include BilletUtil in scope sn_hr_core being called from scope rhino.sandbox
// When the Dynamic Filter script is set to "new global.HRReportUtil().getMyOrganization();"
com.glide.script.RhinoEcmaError: undefined is not a function.
<refname> : Line(1) column(0)
==> 1: new global.HRReportUtil().getMyOrganization();
For the life of me, I cannot figure out why this is happening. The HR: Core, sn_hr_core.BilletUtil(), script is bound to application scope only, you cannot change that if you wanted to. The global script is available for all application scopes.
This is not an easy one, any insight would be greatly appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 01:47 PM
Hi,
The error message "Illegal access to private script include" indicates that the script include being called is marked as private. Private script includes cannot be accessed from outside their own scope, even if the caller has the correct roles and permissions.
In this case, it looks like the "BilletUtil" script include is marked as private in the sn_hr_core scope. You will need to change its visibility to "Protected" or "Public" to be able to access it from your report's dynamic filter.
To change the script include's visibility:
- Navigate to "System Definition" > "Script Includes" in the application menu.
- Search for the "BilletUtil" script include in the sn_hr_core scope.
- Click on the script include to open its record.
- In the "Access" section, change the visibility to "Protected" or "Public".
- Save the record and test your report again.
As for the "undefined is not a function" error, it suggests that the function being called is not defined in the script include. Double-check that the "getMyOrganization" function is defined correctly in your "HRReportUtil" script include and that it is accessible from the report's dynamic filter.
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 02:18 PM
Thanks for the quick reply Rahul.
Unfortunately, there is no "Access" section on a script include. I even showed the XML thinking that it may be hidden. If you were thinking the "Accessible from" field, HRSD prevents you from changing that. You can only access it within scope.
@Rahul Kumar17 wrote:As for the "undefined is not a function" error, it suggests that the function being called is not defined in the script include. Double-check that the "getMyOrganization" function is defined correctly in your "HRReportUtil" script include and that it is accessible from the report's dynamic filter.
I was thinking the same thing. However if I put the same exact line inside a "Scripts - Background" window, and surround it by gs.info, it prints without issue. You cannot assume the sn_hr_core scope for some reason, but it's a global script accessible by all scopes, so you would think HR would be able to access it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 01:24 AM
The solution is to mark the script include as "Client callable"
It took me a while before I found that one,....
So apparantly in the newer versions only Client Callable script includes can be used.
I had quite some functions in a normal script include that were used in New York, that stopped working when we arrived in a new version (San Diego).
We always got an error in the logs while using it from the dynamic filters: com.glide.script.RhinoEcmaError: undefined is not a function. <refname> : Line(1) column(0) ==>
When we used Client Callable script includes (Ajax) these didn't give the error.
So just by flagging the existing normal Script Include as 'Client Callable', I didn't even change anything inside it, so didn't extend it from ajax etc, it worked again....
So setting Client callable | client_callable to TRUE on Script Include is the solution.
Or create a new script include (client callable) with in it a call to the original script include (not client callable) function...