Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Script include parameters

Shaik22
Tera Expert

Hello,

 

1.What are script include parameters.

2.How to send response as array of values from script include BR.

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage

Hello @Shaik22 ,

If you are calling your script include in a BR and want to return array as a output to BR from script include you can do like below .i am just gliding incident table to push all active incidents in an array and return it 

getIncidents :function()
{
var arr=[];
var gr = new GlideRecord('incident');
gr.addQuery('active',true);
gr.query();
while(gr.next())
{
arr.push(gr.number.toString());
}
return arr.toString();
},

 Also parameters are nothing but values which can help you build your logic in your script include.

 

lets say your BR is on incident table and you are calling a script include in it and you need to build a logic in script include based on some value on the incident form. You can pass that value to your script include as a parameter and access that parameter to build your logic.

Example : you want to get incidents assigned to the current person tagged in caller ID field of incident form 

 

var getInc = new your_script_include_name().your_function_name(current.caller_id); //pass current.caller_id as parameter

 

In script include you can access this as below 

your_function_name:function(caller) // you can access this parameter from BR with any meaningful name 

{

gs.info(caller);

},

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks

 

View solution in original post

1 REPLY 1

Mohith Devatte
Tera Sage

Hello @Shaik22 ,

If you are calling your script include in a BR and want to return array as a output to BR from script include you can do like below .i am just gliding incident table to push all active incidents in an array and return it 

getIncidents :function()
{
var arr=[];
var gr = new GlideRecord('incident');
gr.addQuery('active',true);
gr.query();
while(gr.next())
{
arr.push(gr.number.toString());
}
return arr.toString();
},

 Also parameters are nothing but values which can help you build your logic in your script include.

 

lets say your BR is on incident table and you are calling a script include in it and you need to build a logic in script include based on some value on the incident form. You can pass that value to your script include as a parameter and access that parameter to build your logic.

Example : you want to get incidents assigned to the current person tagged in caller ID field of incident form 

 

var getInc = new your_script_include_name().your_function_name(current.caller_id); //pass current.caller_id as parameter

 

In script include you can access this as below 

your_function_name:function(caller) // you can access this parameter from BR with any meaningful name 

{

gs.info(caller);

},

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks