How to call & extend script include in servicenow

Rajababu
Giga Guru

Hi ,

I want to extend one out of box script include "CSEMailUtil" it's out of box and I created my script include which extend OOB script include below sample code :

Client callable : True

var Getfunction = Class.create();

Getfunction .prototype = Object.extendsObject(CSEMailUtil, {


getValue: function(email) {
var value1 = '';
if (gs.nil(email))
return skills;
var emails = email.split(',');
emails = emails.reduce(function(filtered, mailId) {
if (mailId && !gs.nil(mailId.trim()))
filtered.push(mailId.trim());
return filtered;
}, []);

if (!emails || emails.length <= 0)
return value1;
var gr = new GlideRecord('sn_customerservice_channel_config');
gr.addQuery('email_address', emails);
gr.setLimit(1);
gr.query();
if (gr.next())
skills = gr.u_abc + '';
return value1;
},


type: 'Getfunction'
});

 

In email inbound :

 ((new CSEMailUtil).checkCaseChannel(email.to)) && ((new CSEMailUtil).isUserExist(email.from)) ---> do i  need to make changes into it ?

If yes then what ?

1 ACCEPTED SOLUTION

In email inbound I need to provide the as mentioned the get the content .

So in email inbound : It will be as it is where it will verify channel configuration email associated with with Valuefunction(field on the channel) .

Script include(extend into another script include) it provide accessibility to parent script include function :

"Getfunction .prototype = Object.extendsObject(CSEMailUtil, {"

Email inbound action (body):

current.valuefunction = new Getfunction().getValue(email.to);

GetFunction : Script include which extended to CSEMailUtil or another word which provided access to parent script include function .

getValue : Function defined into extend script include .

It working as desired .

View solution in original post

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

refer below link(s) for help

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

How to extend an existing Class in a new script include

How to Extend a Script Include

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Kieran Anson
Kilo Patron

Hi,

You've not really *extended* the CSEMailUtil as you're not invoking any of the CSEMailUtil functions nor overriding them.

What are you wanting to achieve?

I want to add one more method into "CSEMailUtil " oob script include .

Named "getFunction" .

There is existing email inbound action defined which utilize OOB functionality under condition .

In email inbound under condtion utlize CSEMailUtil() :

 ((new CSEMailUtil).checkCaseChannel(email.to)) && ((new CSEMailUtil).isUserExist(email.from))

 

Now How I can add filter for "GetFunction" under above script include .

Hi,

You can update the OOB Script include and add your custom function in it

CSEMailUti.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader