I want to fetch informetion from Server side to Client side on form which three methods available ?

AkPatilakshay
Giga Contributor
 
1 ACCEPTED SOLUTION

Abhishek Kathe
Mega Guru

1) getReference

2) GlideAjax

3) Display Business Rule

View solution in original post

4 REPLIES 4

Eswar Chappa
Mega Sage
Mega Sage

Hi @AkPatilakshay There are like 3 ways to fetch data from Server side to Client side:

Glide Ajax

The GlideAjax class allows the execution of server-side code from the client. GlideAjax calls pass parameters to the script includes, and, using naming conventions, allows the use of these parameters.

 

https://docs.servicenow.com/bundle/vancouver-api-reference/page/script/ajax/topic/p_AJAX.html

 

Get Reference

you can use the getReference() to glide that particular record from client side and access the related record of that Glide Object, you can find the more details here: GlideForm - Client

 

https://www.servicenowguru.com/scripting/client-scripts-scripting/gform-getreference-callback/

 

g_scratchpad

The g_scratchpad object passes information from the server to the client, such as when the client requires information not available on the form. For example, if you have a client script that needs to access the field u_retrieve, and the field is not on the form, the data is not available to the client script. A typical solution to this situation is to place the field on the form and then always hide it with a client script or UI policy. While this solution may be faster to configure, it is slower to execute.

 

You can have detail explanation for every method in the below video:

 

https://www.youtube.com/watch?v=LclUuP-gSN

 

Thanks & Regards,

Eswar Chappa

Mark my answer correct and Helpful if this helps you ðŸ˜€

Nivedita Patil
Mega Sage
Mega Sage

Hi @AkPatilakshay ,

 

There are 3 different ways with which we can access server side data in client script. 

 

1. Using getReference  method

2. Using GlideAjax

3. Using display BR.

 

Mark my answer as accepted solution and helpful if helps you.

 

Thanks,

Nivedita Patil.

Siva Jyothi M
Mega Sage

Hi @AkPatilakshay,

 

Client Side - These run when form loads or any field changes on the client(web browser)

Server side -  These run when user does interaction and updates or inserts or deletes record.

Server scripts run on the server or database. 

 

There are 3 different ways with which we can access server side data in client script.
1. Using getReference method.
2. Using GlideAjax.
3. Using display BR.(g_scratchpad)

Note : We can also use GlideRecord API in client script directly but this is not recommended by ServiceNow. This also impacts health scan report.

Please refer the below link if it helps.

https://www.servicenow.com/community/now-platform-blog/client-side-data-retrieval-the-ultimate-guide...

https://developer.servicenow.com/dev.do#!/learn/courses/tokyo/app_store_learnv2_scripting_tokyo_scri...

 

Please mark this answer as correct and helpful if it solves your issue.

Regards,

Siva Jyothi M.

Abhishek Kathe
Mega Guru

1) getReference

2) GlideAjax

3) Display Business Rule