
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 06:39 AM
Can we use "Current" object in Script Include? Please be specific. Yes or No.
If 'Yes', then how? Shouldn't we need to pass the "Current" object to the function or instantiate a GlideRecord object in the script include function?
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 09:48 PM
Indeed. Here goes an example using a classless Script Include:
Script include Name: sayHello
Script:
function sayHello(){
gs.addInfoMessage(current.number);
}
I can then call that script include from an incident onBefore insert/update Business Rule with the script:
function onBefore(current, previous) {
sayHello();
}
And upon an insert or update of an incident it will display the incident number as an Info Message in the screen.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 06:45 AM
You use current to pass to the script include, like myScriptInclude(current.number), then in the script include, you have myScriptInclude(number) and you process the number in a GlideRecord query, then return the answer. I don't think you can use current in a script include the way you use it in a business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 10:30 AM
Yes.
- When you pass it in a function call previously instantiating the class it is a part of.
-When you use Script Include as a function call without the class wrapper. You can then reference it as current, without having to pass it in.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 09:44 PM
Hi Masha,
Can you please elaborate?
Thanks
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 09:48 PM
Indeed. Here goes an example using a classless Script Include:
Script include Name: sayHello
Script:
function sayHello(){
gs.addInfoMessage(current.number);
}
I can then call that script include from an incident onBefore insert/update Business Rule with the script:
function onBefore(current, previous) {
sayHello();
}
And upon an insert or update of an incident it will display the incident number as an Info Message in the screen.
Thanks,
Berny