The CreatorCon Call for Content is officially open! Get started here.

Can we use "current" in Script include

Sachin G K1
Kilo Sage

As we know, to access server side value we use make use object "current" in Business Rule. Similarly can we use object "current" in "Script Include". If not what are other ways to access server side value in script include except "GlideRecord".

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

As Mohith suggested above, to gain deeper understanding you can refer to below article:

Ref link:
Can Script Includes Use the "current" Variable?

The correct way to access the “current” object in a Script Include, is to pass it into the function you’re calling (and preferably, to use a variable name within the method other than “current”).

Note: Keep in mind that when handling objects in JavaScript, you’re passing by reference, not by value. This basically means that anything that you do to the object in the Script Include, will also happen to that object in the Business Rule - even if your SI method doesn’t return anything!
Since this is the “short” solution, I’ll spare you the explanation of
pass-by-reference (PBR). If you want to know more about it - and you should - you can read more in my article on the subject, here.

 

Best Regards
Aman Kumar

View solution in original post

13 REPLIES 13

Hi Aman,

So if we want to pass server side values to client script. Is it only possible by using gliderecord in scriptinclude and ajax in client script?

Yes,

You can also use getReference to fetch values from reference field but that is not best practice and exposes data to illegal access

Best Regards
Aman Kumar

Oh great!! thank you Aman

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Members have already mentioned the points.

What's your exact use-case where it's not working?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader