- 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 07:16 AM
Hi Ankur,
Thanks so much, that did the trick. The service catalog item is now submitting fine and I'm able to override the OOB script include functions via our custom script include.
Highly appreciate the quick responses provided by you and Pradeep. Thumbs up!
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 07:28 AM
You are welcome.
It would be nice if you share the approach/update you did to the script to skip hidden variables so that it benefits future readers as well.
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-02-2020 08:42 PM
Hi,
Got the scenario.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
