ServiceNow GlideRecord Mark Read-Only | ServiceNow GlideRecord Tips and Tricks
Import
·
Oct 31, 2022
·
article
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
- What is GlideRecord
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
View original source
https://www.servicenow.com/community/developer-articles/servicenow-gliderecord-mark-read-only-servicenow-gliderecord/ta-p/2362775
