- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-31-2022 05:09 AM
Hi All,
I hope you are doing fine.
- As a ServiceNow developer, the thing which you will encounter daily is GlideRecord API. Whenever we have to retrieve any information from the database the GlideRecord is the primary API.
- Let's first try to understand what is GlideRecord in ServiceNow.
- As per ServiceNow docs, the ServiceNow GlideRecord class is the way to interact with the ServiceNow database from a script. See the GlideRecord API reference for a complete list of methods.
GlideRecord interactions start with a database query.
- The generalized strategy is:
- Create a GlideRecord object for the table of interest.
- Build the query condition(s).
- Execute the query.
- Apply script logic to the records returned in the GlideRecord object.
- In my project, I have faced a scenario where we have created a function that returns a GlideRecord object as an output, and our intention is just to provide read access to the object via GlideRecord.
- But in most cases, people will start modifying that object by updating a specific attribute on that record which in return changes the base values for the record.
- We were looking at the feasibility to make this GlideRecord restricted from the update that's where I encountered this hidden concept.
In this tutorial, we will be looking at the way to make GlideRecord Read-only so that no one can update the returned GlideRecord. Isn't it amazing?
- Agenda:
- What is GlideRecord
- Problem statement for the exposure of GlideRecord Object
- How we can mark the gLideRecord to ReadOnly
- Function to check if the GlideRecord is ReadOnly
- Demo
If you like this video please subscribe to my channel Technomonk for more such videos in the future.
Regards,
Amit Gujarathi
(Technomonk)
Technomonk Youtube: https://www.youtube.com/c/TechnoMonkAmit
Amit Gujarathi Linkedin: https://www.linkedin.com/in/amit-gujarathi-98632a175
TheTechnomonk.com : https://thetechnomonk.com/
ServiceNow Community Amit Gujarathi: https://www.servicenow.com/community/user/viewprofilepage/user-id/265565
GitHub: https://github.com/amigujarathi
- 1,383 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is interesting, thanks for sharing @Amit Gujarathi
I have mostly used GlideRecord objects to update the value in the record . If possible can you share a business case where just we don't want to update record and just want the record value..
Moreover, thanks again.
Happy to learn something new !
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Manal,
There are couple of use case which I can think of wherever we want to restrict it the Glide Record object.
Lets consider a simple scenario where I have custom table which holds the configurations and script which is required in order to drive certain logic in my scripted rest API.
So I have created a function which will expose the Glide record for configuration which then can be used to drive further logic based on the Glide Record information.
Now this Glide Record is vulnerable to the updates if any one updates the configuration by mistake.
So I will make the Glide Record read only so that they can access the information to drive the process but cannot update the base configuration which makes it error prone.
Hope it answers your question.
Regards,
Amit Gujarathi
(Technomonk)
Technomonk Youtube: https://www.youtube.com/c/TechnoMonkAmit
Amit Gujarathi Linkedin: https://www.linkedin.com/in/amit-gujarathi-98632a175
TheTechnomonk.com : https://thetechnomonk.com/
ServiceNow Community Amit Gujarathi: https://www.servicenow.com/community/user/viewprofilepage/user-id/265565
GitHub: https://github.com/amigujarathi