how to grab Request Item attachment ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 10:48 AM
Hey guys,
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id',current.sys_id); // unable to find the current.sys_id
attachment.addQuery('table_name','sc_req_item');
attachment.query();
while(attachment.next()){
gs.addInfoMessage('inside attachment' + attachment.table_sys_id + ''+current.sys_id);
}
never gets into the while loop
sys_attachment table contains the information of the request table but for some reason i can not access it when the request is submited.
i am running the business rule after the request item is inserted.
when i use the rest api can find the attachment
https://########.service-now.com/api/now/attachment?table_sys_id=6d08141e0f302200d53d0dbce1050eaf
{
"result": [
{
"table_sys_id": "6d08141e0f302200d53d0dbce1050eaf",
"size_bytes": "3707",
"download_link": "https://dev10222.service-now.com/api/now/attachment/1808941e0f302200d53d0dbce1050e81/file",
"sys_updated_on": "2016-07-25 18:09:50",
"sys_id": "1808941e0f302200d53d0dbce1050e81",
"image_height": "4",
"sys_created_on": "2016-07-25 18:09:50",
"file_name": "Screen Shot 2016-07-21 at 8.00.27 AM.png",
"sys_created_by": "admin",
"compressed": "true",
"average_image_color": "#ebebeb",
"sys_updated_by": "admin",
"sys_tags": "",
"table_name": "sc_req_item",
"image_width": "2",
"sys_mod_count": "2",
"content_type": "image/png",
"size_compressed": "3599"
}
]
}
any help is really appreciated.
regards
NB
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:36 PM
Unfortunately there's a problem with that - that particular update occurs without triggering any Business Rules. Ran into that in another post (Improving the Attachments List View ).
Back to Robert's question - "Can I ask to what purpose you're "grabbing" the current attachment?"
When do you need to get the attachment? For what purpose? Maybe we can help if we fully understand the requirement and point you in another direction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:44 PM
Hey ,
requirement is
1> need to get the download url of the attachment and need to map it to request item number
2> need to store the above info in a table which i will be using later with my middleware
so steps followed
1> verify if attachment is present
2> if attachment is present ( map it with the request item number in a table )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 03:04 PM
OK, that helps.
Is it for a particular catalog item or them all? If a particular one, you could add a Run Script activity to the workflow (assuming you have one).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:37 PM
how do we run a business rule when the copy is made ?
is it treated as a update ? or query ?
how do we set this up
here how it looks
when the file uploaded
{
"result": {
"table_sys_id": "401f46260f702200d53d0dbce1050e3f",
"size_bytes": "3707",
"download_link": "https://dev10222.service-now.com/api/now/attachment/3d1f4ea20f702200d53d0dbce1050eb6/file",
"sys_updated_on": "2016-07-26 21:28:40",
"sys_id": "3d1f4ea20f702200d53d0dbce1050eb6",
"table_name": "sc_cart_item",
}
}
after user submit the request
{
"result": {
"table_sys_id": "d840d6a20f702200d53d0dbce1050e76",
"size_bytes": "3707",
"download_link": "https://dev10222.service-now.com/api/now/attachment/3d1f4ea20f702200d53d0dbce1050eb6/file",
"sys_updated_on": "2016-07-26 21:28:40",
"sys_id": "3d1f4ea20f702200d53d0dbce1050eb6",
"table_name": "sc_req_item",
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:39 PM