CAD · Question #220
Which method in the GlideRecord API is used to update a record in the database?
The correct answer is A. gr.update(). The gr.update() method within the GlideRecord API is specifically used to save changes made to an existing record in the database.
Question
Which method in the GlideRecord API is used to update a record in the database?
Options
- Agr.update()
- Bgr.insert()
- Cgr.save()
- Dgr.setValue()
How the community answered
(28 responses)- A89% (25)
- B4% (1)
- C7% (2)
Why each option
The `gr.update()` method within the GlideRecord API is specifically used to save changes made to an existing record in the database.
The `gr.update()` method saves any changes made to the current GlideRecord object to the database, effectively updating the corresponding record. It is essential for persisting modifications to existing records within server-side scripts.
`gr.insert()` is used to create a new record in the database, not update an existing one.
`gr.save()` is not a standard GlideRecord method for persisting changes; typically, `insert()` or `update()` are used.
`gr.setValue()` is used to set the value of a specific field on a GlideRecord object, but it does not save the changes to the database.
Concept tested: GlideRecord record update method
Source: https://docs.servicenow.com/bundle/utah-application-development/page/app-store/dev_portal/API_reference/GlideRecord/concept/gr-update.html
Topics
Community Discussion
No community discussion yet for this question.