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
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  ||  9x 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

Ankur Bawiskar
Tera Patron
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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Could you please elaborate more and provide some examples if possible when we should these methods and when not ?

Thanks!

@sndevastik 

I don't have a direct example, but this is based on my experience and knowledge and past discussion we had with ServiceNow support team.

Thank you for marking my response as helpful.

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

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

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!