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

Regarding GlideRecord on Client side

darshan-pra
Tera Expert

The Below Onload Client script in executing on PDI here accessing data through Glide Record.  Is a expected behavior  , what should be ideal case for glide Record in client side  , is through error or provide output .

 

function onLoad() {
   //Type appropriate comment here, and begin script below
   alert('hello');
   var test=new GlideRecord('incident');
   test.query();
   if(test.next())
   {
    alert('Found incident' +test.getValue('number'));
   }
   
}
1 ACCEPTED SOLUTION

@darshan-pra  it would work in Native UI but not in portal, scoped app or mobile as mentioned by @Ankur Bawiskar

The GlideRecord API is the primary means of interfacing with the database on the server-side code. Its best not to mix server side APIs with client scripts as it could break in Service Portal, mobile and future upgrades. Use best practices so that your code is scalable and optimised. ServiceNow has GlideAjax class to call server side script from client side and fetch necessary data, you can make use of it.

Docs: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_referenc...

 

https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_referenc...

 

Regards,

Ehab Pilloor

 

View solution in original post

6 REPLIES 6

so it will work in global scope ... ? also could you please provide more info why not recommended and what are then impact are there if used .. 

maheshkhatal
Mega Sage
Mega Sage

@darshan-pra , it may work for native UI but not in portal UI. Also its not about what is working but also about if it is following the best practices. The best practice is to use GlideAjax and for processing between client and server side data. 

Thank you,

Mahesh.