Can't GlideQuery sys_attachment table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 07:28 AM
I am not sure what's going on. I have queried the attachment table in the past but for some reason my client script below doesn't work.
My first alert does show the sys_id but the 2nd test alert doesn't show up at all. I have tracked this down to the query I am doing on the attachment table. When all three query lines are commented, both alerts work. When the first one is active, I only get the first popup.
Any idea what's going on?
function onLoad() {
alert(g_form.getUniqueValue());
var att = new GlideRecord('sys_attachment');
//attachment.addQuery('table_sys_id', g_form.getUniqueValue());
//attachment.query();
alert('2');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 07:32 AM
You should not use glideRecord client side. If you do you should use a callback
In your script the var name should not be attribute, but att, as that is how you declared it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 07:48 AM
I have tried in incident form by glidequerying the attachment table. It is working after couple of seconds when the attachment was added. What is your usecase in putting in OnLoad client script for new record.
Try put in onChange, it will work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 07:55 AM
As mentioned by Arnoud, using GlideRecord client-side is not a good practice. Depending on what you are doing, a Display Business Rule which populates a scratchpad variable would be better. All depends what you are actually trying to do.
However, the issue is you are causing a runtime error because you declare a variable called "att" but then use "attachment.addQuery". Try using "att.addQuery" instead.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 09:34 PM
Glide Record at Client Side - This is why you are getting Issues. It Should be used at Server Side scripts.
Glide Ajax /Display BR will be another way of doing this.
Some good blog on this:
http://www.snc-blog.com/2012/07/18/client-scripting-gliderecord-query-using-a-callback-function/
Regards
RP