Why does my GlideRecord update keep creating new record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 07:57 PM
Hi
I have an approval workflow (that works fine). If the workflow is approved there's a step to either update the status as "approved" in exciting record which i opened. My problem is that, whenever I execute the glideRecord update() function it creates a new record instead updating the existing record. Here's a cut down version of the code:
code:
gr.setDisplayValue('u_status',"Approved");
gr.update();
}
can someone help me how to solve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:21 PM
Hi, if the glide query has not returned an object\valid record then the update() function will insert a new record.
You don't make it clear which table you are running the BR on, but I would suspect current.sys_id is a task or an approval record?
And your query probabaly needs to be a dot walk to another table ('u_os_storage') via a reference field?
something along the lines of
current.myCiField.sys_id or current.myTaskField.myCiField.sys_id
Perhaps add some logging\debugging to confirm that current.sys_id is the value you are expecting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 09:10 PM
Hey sharmi,
Try following code, might help you.
gr.setDisplayValue('u_status',"Approved");
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 09:25 PM
Hello,
If you are getting problem in these part of code:
while(gr.next()){
gr.setDisplayValue('u_status',"Approved");
gr.update();
}
then use, if(gr.next())
Please mark it as Correct and Helpful, if applicable. Thanks!
Warm Regards,
Prithviraj Howal
SNOW Developer