- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 07:48 AM
Hello,
1.What are script include parameters.
2.How to send response as array of values from script include BR.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 08:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 08:01 AM
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