Object.extendsObject - multiple ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2019 01:48 AM
I have a custom script include which extends an OOB one - all good
What I now need is to make my script include into an client compatible script, but obviously the Object.extendsObject needs to change to Ajax. Is there a way to extend to multiple objects, so Ajax and the OOB include ?
I had a look at gs.include and that did not work when I did a few initial tests.
For now I will work with an Ajax Include that simply calls the one I really want to call
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2019 01:51 AM
Hi,
you can have a client callable script include which holds function which can be called from server side.
what is your exact requirement?
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
‎06-19-2019 02:36 AM
Yes that is what I am trying to do and is why I need to change my Script Include.
It has a number of functions which until now have not needed to be called client side, but a new requirement has meant that I want to call this existing Script include instead of rewriting some code for no reason - and potentially having 2 sets of code to maintain.
My include currently extends an OOB include so I reference mine and call my functions and the OOB functions - it works and to ensure compatibility with existing code, needs to still do this.
For my new requirement I want to make my Script Include client callable, but STILL extend the OOB include
so right now my include has
my_include.prototype = Object.extendsObject(global.OOB_Include, {
When you change to be Client callable, the Object.objectExtends changes to
my_include.prototype = Object.extendsObject(AbstractAjaxProcessor, {
I want a way that the script can incorporate BOTH
you cannot just use Object.extendsObject(global.OOB_Include, AbstractAjaxProcessor, {
I did try gs.include and referencing the OOB include but it did not work when I tried it
I would prefer to keep it all in a single Script include which is client callable and still extends an OOB script.
Right now, I am going to write a client callable version that simply calls the Server Side version instead - it works, but is not as neat and you have to remember any code added to the Server side include needs to be presented in the client callable version too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2025 03:56 AM - edited ‎02-10-2025 03:56 AM
Hi @poyntzj ,
I have created this example where you can inherit from multiple classes using Object.extendsObject() function.
You can find more details here: Master Good Software Architecture with Object.extendsObject() | A Guide for ServiceNow Developers