The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can we use "Current" object in Script Include? Please be specific. Yes or No.

SwarnadeepNandy
Kilo Sage

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.

1 ACCEPTED SOLUTION

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


View solution in original post

14 REPLIES 14

Mike Allen
Mega Sage

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.


Masha
Kilo Guru

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.


Hi Masha,


Can you please elaborate?



Thanks


Swarnadeep Nandy


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