As GlideRecord is on server side why GlideForm and GlideUser works on client side ??

harshshree7
Tera Contributor

As Glide Record is on server side why Glide form and Glide User works on client side ??

4 REPLIES 4

Arun_Manoj
Mega Sage

Hi @harshshree7 ,

 

GlideRecord: GlideRecord is a special Java class (GlideRecord.java) that can be used in JavaScript exactly as if it was a native JavaScript class.

 

  • is used for database operations instead of writing SQL queries.
  • is an object that contains zero or more records from one table. Another way to say this is that a GlideRecord is an ordered list.

GlideUser in Client Script

The GlideUser API provides methods that access information about the current user and current user roles. Using this API avoids the need to use the slower GlideRecord queries to get user information.

GlideUser methods and properties are accessed through a global object (g_user) that is only available in client scripts.

This API:
  • contains name and role information about the current user.
  • is typically used in client scripts and UI policies but is also found in UI actions that run on the client.
  • cannot be used in business rules or UI actions that run on the server.
    Feature/Aspect GlideRecord GlideUser (g_user)



    PurposeInteract with database tables(GlideRecord)Access current user session details (GlideUser)
    TypeServer-side APIClient-side global object
    ScopeBusiness Rules, Script Includes, Scheduled JobsClient Scripts, UI Policies, Catalog Client Scripts
    Used ForQuerying, inserting, updating, deleting recordsChecking user roles, name, ID, and session info
    ReturnsGlideRecord object representing recordsUser info as string or boolean
    Access to DBYesNo
    Examplegr = new GlideRecord('incident');g_user.hasRole('admin')
    Common MethodsaddQuery(), get(), next(), insert()hasRole(), getName(), getUserID()
    ContextBackend operations and logicFrontend behavior control
    SecurityNeeds appropriate roles to access tablesReflects current user’s session privileges

    Please mark my answer as helpful/correct if it resolves your query.

    Regards,

    Arun Manoj

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @harshshree7 ,

Sorry but it's not "why" on server side or client side.

That's the official instance recommended methods designated and defined to work for Server side and Client side respectively.

 

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

Ankur Bawiskar
Tera Patron
Tera Patron

@harshshree7 

that's how ServiceNow has designed it.

GlideRecord does work in client side but has limited capabilities, not all GlideRecord methods which are supported in server side work in client side.

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

OlaN
Giga Sage
Giga Sage

Hi,

There are a whole lot more APIs from ServiceNow that you can use. And they all have different purposes and functionality, and, as you mentioned, they are often used on different parts, as server-side or client-side.

 

For a complete reference, you can look here: Reference | ServiceNow Developers