Sanket Khabiya
Kilo Sage

How to Extend the Script Include With Your Custom Made Script Include?


Script Include 1 :  Client callable 

var SC_Assignment3_userinfo = Class.create();
SC_Assignment3_userinfo.prototype =
Object.extendsObject(AbstractAjaxProcessor, {
user_info2:function(){
return 'Inherited SuccessFully';
},
type: 'SC_Assignment3_userinfo'
});

============================================================================================

Script Include 2 :  Client callable 

var Inheritance_in_script_include = Class.create();
Inheritance_in_script_include.prototype =
Object.extendsObject(SC_Assignment3_userinfo, { //To Extend the another Script Include just remove the 'AbstractAjaxProcessor', and add Object of 'Script Include 1', like 'SC_Assignment3_userinfo'.
inher:function(){
var obj = this.user_info2(); //SC_Assignment3_userinfo,
return obj;
},
type: 'Inheritance_in_script_include'
});
===========================================================================================
Catlog Client Script to Call Script Include 2
OnChange of field : caller_id

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('global.Inheritance_in_script_include');//Contains Script Include Name
ga.addParam('sysparm_name','inher');//This contains the function name
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
}

Comments
vkachineni
Kilo Sage
Kilo Sage

Nice work.

 

Suggestions if I may:

Can you modify the line

ga.addParam('sysparm_name','inher');

to call the base class function to show that it is available

ga.addParam('sysparm_name','user_info2');

 

You should take it further and also show what happens when there is a function name with same name in the sub class. 

Sanket Khabiya
Kilo Sage

Sure, i will try this!!

Version history
Last update:
‎08-23-2019 07:09 AM
Updated by: