how to add two functions from script include in a reference qualifier

akhila13
Tera Expert

how to add two functions from script include in a reference qualifier

 

SeatUtils is the script include and  getbcp3() is a function. i have another function getbcp2()

 

have to call both in single reference qualifier

 

tried javascript:new SeatUtils().getbcp3()+new SeatUtils().getbcp2(); but not working fine

 

find_real_file.png

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

use this to call function inside script include 

eg this.functionName() 

I have two function and want to merger both result into third function it will be used like below. 

 

get1: function(){

 

return 'hello';

},

get2: function(){

 

return 'harsh';

}

 

final: function(){

 

return this.get1()+','+this.get2();

 

}

 

If my answer helped you, kindly mark it as correct and helpful.

View solution in original post

12 REPLIES 12

MrMuhammad
Giga Sage

Is there any specific reason you have two different functions to call in a single reference qualifier? If those functions are being used separately in some scripts then I would suggest creating a third function and calling both inside that process and return required result and call the third function inside the reference qualifier.

However, I think you can call two different functions in SI like this.

 javascript: var SI = new SeatUtils(); SI.getbcp3()+"^"+ SI.getbcp2();

Before executing place logs inside both the functions and see if logs are generated. I am not sure if the returned output will make sense or not following this way.

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

tried with this..

 

but its not working.

Also tried calling the third function

 

getbcp3: function() {

var locationList = [];
var location = new GlideRecord('fpv_element');
location.addQuery('sys_id','fbac3ccfdbfd9c507b06d776489619ff');
location.query();
while(location.next())
{
locationList.push(location.sys_id.toString());
}
return 'sys_idIN'+locationList;
},
getbcp2: function() {

var locationList1 = [];
var location1 = new GlideRecord('fpv_element');
location1.addQuery('sys_id','005e1b861ba07f845c407661cd4bcb57');
location1.query();
while(location1.next())
{
locationList1.push(location1.sys_id.toString());
}
return 'sys_idIN'+locationList1;
},

getbcp1: function() {

var isValidFunction = getbcp1() && getbcp();

return isValidFunction;
},

 

 

its also not working

 

Pratiksha Kalam
Kilo Sage

Hello,

see this thread having same requirement but I think you need to add some spaces in between functions

Check below script,

https://community.servicenow.com/community?id=community_question&sys_id=78ea587fdbe59f000e3dfb651f96...

 

 

If answer is helpful please mark correct!

Thanks,

Pratiksha

tried with adding space but not working