We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Why isn't setClientData() / putClientData() preferred over GlideAjax or getReference for server-to-c

sndevastik
Tera Contributor

Hi Community,

 

While exploring different ways to pass values from the server side to the client side in ServiceNow, I recently came across the use of putClientData() on the server side and getClientData() on the client side.

 

These methods seem to allow direct transfer of data between server and client without needing a separate GlideAjax call or getReference().

 

Given this capability, I'm curious — why are GlideAjax and getReference() still preferred or commonly used in practice over putClientData() / getClientData()?


Are there any limitations, best practice considerations, or disadvantages associated with the use of putClientData() that developers should be aware of?

 

Would love to hear your thoughts or real-world experiences.

 

Thanks!

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron

@sndevastik 

data stored with putClientData() is stored in User' session and if we use it excessively it can lead to performance impact when more users are using that form.

Data stored in session might be risky.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

sunil maddheshi
Tera Guru

@sndevastik I think they are best suited for passing a few small, simple server-side values during form load. It’s not ideal for large datasets or complex structures. In practice, I’ve seen it used typically for setting basic flags like 'isManager', 'hasSpecialRole', or for preloading simple lookups. However, in most real-world scoped applications or HRSD implementations, client-server interactions predominantly rely on GlideAjax due to its greater flexibility and dynamic capabilities.

 

Please mark correct/helpful if this helps you!

View solution in original post

4 REPLIES 4