- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 11:25 AM
Can someone please tell me what is wrong with the below code
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 04:09 PM
The GlideRecord method is no longer recommended due to its performance impact. it retrieves all fields in the requested GlideRecord when most cases only require one field. Instead, use g_scratchpad on a display business rule or use GlideAjax methods.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 06:38 PM
I am not sure of .getNumber. Instead you should use addQuery() or addEncodedQuery(). Please try following code-
function onLoad() {
var gr = new GlideRecord("incident");
gr.addQuery("number", "INC0000031");
gr.query();
if (gr.next()) {
g_form.setValue('impact', "3");
}
}
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 06:43 PM
Amit,
Great response. Came here to say exactly this.
Also https://www.youtube.com/watch?v=H_eoB6LXPrs
Here's a video on why variables shouldn't be named gr

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 06:50 PM - edited 05-14-2024 06:51 PM
Hi @keep_it_simple you cannot use glide record query in client side scripts, convert them to script include and use glide ajax to call,
Also you cannot compare with number compare with sysid instead.
Example: create a client callable script include
Script Include:
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 09:08 PM
function onLoad() {
var gr = new GlideRecord("incident");
gr.addQuery("number", "INC0000031"); // Query for the specific incident number
gr.query(); // Execute the query
if (gr.next()) {
// If the record exists, set the 'impact' field value to "3"
g_form.setValue('impact', "3");
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 09:08 PM
function onLoad() {
var gr = new GlideRecord("incident");
gr.addQuery("number", "INC0000031"); // Query for the specific incident number
gr.query(); // Execute the query
if (gr.next()) {
// If the record exists, set the 'impact' field value to "3"
g_form.setValue('impact', "3");
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks