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

SwarnadeepNandy
Mega 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

And this is the result. I hope it helps




IncidentNumber.jpg


Here is the champ.! Thanks berny. it was much needed for me.



Regards,


Atul Kumar


lol! You're welcome Anul niit_techie !



Have a good one!



Thanks,


Berny


So if i call this script include from any br(associated with a particular incident), Can it recognise the incident?


It works only for classless scripts. That is script include with Class.create(); statement