- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2020 07:52 AM
In our HR service catalog on our HR portal we have many service catalog items that leverage record producers to turn employees' requests into HR cases. Out-of-the-box (OOB), the HR record producer scripts call functions in the sn_hr_core.hr_ServicesUtil script include to pass the information entered by the employee into the case.
We now have a requirement that demands changes to these functions. We don't want to customize the OOB functions, and are instead looking at creating a wrapper around this script include to override the functions. So far however, we've been unable to get this to work.
What we've done is create a custom script include within the same sn_hr_core scope that overrides the functions as follows:
var SIG_hr_ServicesUtil = Class.create();
SIG_hr_ServicesUtil.prototype = Object.extendsObject(sn_hr_core.hr_ServicesUtil, {
initialize : function(_case, _gs) {
sn_hr_core.hr_ServicesUtil.initialize.call(_case, _gs);
},
createCaseFromProducer : function(producer, rpId) {
... (our custom code here)
},
type: 'SIG_hr_ServicesUtil'
});
In our record producer script we call the custom function as follows:
new sn_hr_core.SIG_hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
However, when doing so and submitting a service catalog item from our portal, we get an error and the overriding is not working:
org.mozilla.javascript.EcmaError: undefined is not a function.
Caused by error in <refname> at line 1
==> 1: new sn_hr_core.SIG_hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
What are we overlooking here? Is it even possible to override the OOB functions without customizing the script include?
Best regards,
Pascal Frencken
IT Architect, Signify, The Netherlands
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 06:47 AM
Hi,
You should create that script include in HR Core Scope and Accessible from All scopes.
the OOB Script Include is in HR Core Scope -> hr_ServicesUtil
Are you trying to include this in record producer present in global scope
If you are trying to add restricted caller access then source scope should be global scope
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 01:33 AM
I just tried adding as per what you mentioned.
I didn't mention anything in script but just a log and log came in without any error
You can check the updated line and then try to enhance the code if it removes the error
Below is the updated line
var SIG_hr_ServicesUtil = Class.create();
SIG_hr_ServicesUtil.prototype = Object.extendsObject(sn_hr_core.hr_ServicesUtil, {
initialize : function(_case, _gs) {
new sn_hr_core.hr_ServicesUtil(_case, _gs);
},
createCaseFromProducer : function(producer, rpId) {
gs.info('ARB my function called');
},
type: 'SIG_hr_ServicesUtil'
});
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 03:44 AM
Hi Ankur,
Thanks for the follow-up. This change to the initialize() function seems to work in my PDI.
Will try the same in our company instance to see if that resolves the issue, and confirm here when successful.
Best regards,
Pascal Frencken
IT Architect, Signify, The Netherlands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 04:35 AM
Thanks for confirming.
Do keep us posted and mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 05:07 AM
I have tested this in our company instance. Unfortunately there it's been less successful, there seems to be a cross scope issue. This is what I'm getting when submitting a catalog item:
I tried adding a cross scope privilege as follows:
However this didn't resolve the issue. Any idea what I need to do?
Best regards,
Pascal Frencken
IT Architect, Signify, The Netherlands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 06:47 AM
Hi,
You should create that script include in HR Core Scope and Accessible from All scopes.
the OOB Script Include is in HR Core Scope -> hr_ServicesUtil
Are you trying to include this in record producer present in global scope
If you are trying to add restricted caller access then source scope should be global scope
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader