Script include Extension question

tahnalos
Kilo Sage

I want to ask some general questions regarding extending a pre-existing Script include.  As an example, please refer to the hr_PortalUtil Script include.

 

1) Given that this script include is in the Employee Center Core scope, if I extend it, can I use a custom scope that I am using to build my own app?  Or does it strictly have to be Employee Center Core?

 

2) The initialize () function of the hr_PortalUtil has some scripting in it even has a parameter passed through to the initialize function itself.  If I extend hr_PortalUtil, do I need to copy the same initialize function with the scripting involved?

 

3) There are some function definitions that are outside the main Prototype function (see hr_PortalUtil.getActualCaseRecord for an example).  There are also some variable definitions that are also outside the main Prototype function.   Are these also accessible in an extended Script include?

 

I have extended other script includes before but this one is quite unusual to the point I am asking these questions.  Thanks for your help.

1 ACCEPTED SOLUTION

Tanushree Maiti
Kilo Patron
1) Yes, you can extend the hr_portalUtil  script include from a custom scope (application). However, this is a cross-scope operation, which means you must configure the necessary access privileges
2)Only if you need to override or preserve custom behavior.
  • When you extend a Script Include, the parent’s  initialize ()  automatically runs unless you override it.

  • If you do NOT define  initialize () in your child class → parent’s version runs as-is

3. Variables outside prototype - Not Accessible
   Static methods outside prototype  generally static or class-level functions. 
You can call these functions from your extended script include, but again, this might require cross-scope access .
e.g hr_PortalUtil.getActualCaseRecord()  will work.
 
 
 
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

View solution in original post

3 REPLIES 3

Tanushree Maiti
Kilo Patron
1) Yes, you can extend the hr_portalUtil  script include from a custom scope (application). However, this is a cross-scope operation, which means you must configure the necessary access privileges
2)Only if you need to override or preserve custom behavior.
  • When you extend a Script Include, the parent’s  initialize ()  automatically runs unless you override it.

  • If you do NOT define  initialize () in your child class → parent’s version runs as-is

3. Variables outside prototype - Not Accessible
   Static methods outside prototype  generally static or class-level functions. 
You can call these functions from your extended script include, but again, this might require cross-scope access .
e.g hr_PortalUtil.getActualCaseRecord()  will work.
 
 
 
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hi Tanushree

Trying to set up the Application Cross Scope access and I'm not sure if I'm doing it correctly:
Source Scope: <my application>

Target Scope: Employee Center Core

Target Name: hr_PortalUtil

Operation: Execute API

Is this correct?  Would the extended script include from our custom application access the hr_PortalUtil script?

tahnalos
Kilo Sage

Thanks for your assistance.  I will look into the work I am doing and see what else needs to be done.