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 01:23 PM
Hrmmm. Can I ask to what purpose you're "grabbing" the current attachment?
Reason I ask is you can approach it from the opposite angle. Run the business rule on the attachment table and condition precisely for those attachments where sc_req_item is the source table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 01:28 PM
the purpose here is i need to get the attachment which user upload when he raises a service catalog request.
tried that too ( at the point when the user uploads the attachment the the attachment is stored in ref to sc_cart_item table )
after the request is submitted the table is referenced to sc_req_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:03 PM
Right... so why not write a business rule that only triggers when an attachment record registers a hit on sc_req_item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:21 PM
how do we do that ?
business rule on sys_attachment is triggered wher the user attaches the file at that point it still refers to sc_cart_item table.
i could grab the attachment.sys_id but how will i map it to request item ( sc_req_item ) ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 02:28 PM
I think I see where Robert is going...
At some point the sys_attachment record is changed from pointing to sc_cart_item to sc_req_item (or a copy is made.) If the business rule is watching the sys_attachment tale AND has a condition where the table name is sc_req_item, you've got your info.