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-27-2016 06:13 AM
ok in this case i can see your issue...
you could conceivably write a br on the sysatachment table.. that looks first at the table if it is requested item.. and then checks the record.item to see if it is the right item. if so copy it. if not ignore it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 11:12 AM
step 1
request :
response :
{
"result": [
{
"sc_catalog": "",
"upon_approval": "proceed",
"location": "",
"expected_start": "",
"close_notes": "",
"additional_assignee_list": "",
"impact": "3",
"urgency": "3",
"billable": "false",
"correlation_id": "",
"recurring_frequency": "yearly",
"sys_tags": "",
"sys_domain": {
"link": "https://dev10222.service-now.com/api/now/v1/table/sys_user_group/global",
"value": "global"
},
"description": "",
"group_list": "",
"priority": "4",
"request": {
"link": "https://dev10222.service-now.com/api/now/v1/table/sc_request/2d08141e0f302200d53d0dbce1050eaf",
"value": "2d08141e0f302200d53d0dbce1050eaf"
},
"delivery_plan": "",
"sys_mod_count": "0",
"quantity": "1",
"work_notes_list": "",
"estimated_delivery": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "",
"delivery_task": "",
"sys_updated_on": "2016-07-25 18:09:55",
"parent": "",
"work_end": "",
"number": "RITM0010046",
"closed_by": "",
"work_start": "",
"cat_item": {
"link": "https://dev10222.service-now.com/api/now/v1/table/sc_cat_item/e212a942c0a80165008313c59764eea1",
"value": "e212a942c0a80165008313c59764eea1"
},
"business_duration": "",
"price": "1100",
"activity_due": "",
"correlation_display": "",
"company": "",
"active": "true",
"due_date": "2016-07-30 18:09:55",
"assignment_group": "",
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"state": "1",
"user_input": "",
"sys_created_on": "2016-07-25 18:09:55",
"approval_set": "",
"reassignment_count": "0",
"stage": "waiting_for_approval",
"configuration_item": "",
"opened_at": "2016-07-25 18:09:55",
"short_description": "Acer Aspire NX. The corporate standard laptop for sales employees. 2.5 GHz Intel Core i5 processor. 750 GB hard drive.",
"order": "",
"sys_updated_by": "admin",
"upon_reject": "cancel",
"approval_history": "",
"recurring_price": "100",
"work_notes": "",
"calendar_duration": "",
"sys_id": "6d08141e0f302200d53d0dbce1050eaf",
"approval": "not requested",
"sys_created_by": "admin",
"assigned_to": "",
"wf_activity": "",
"sys_domain_path": "/",
"cmdb_ci": "",
"opened_by": {
"link": "https://dev10222.service-now.com/api/now/v1/table/sys_user/6816f79cc0a8016401c5a33be04be441",
"value": "6816f79cc0a8016401c5a33be04be441"
},
"rejection_goto": "",
"sys_class_name": "sc_req_item",
"context": "",
"backordered": "false",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "0",
"comments": ""
}
]
}
step 2 attachment table
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"
}
]
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 11:16 AM
Thank you. I'm not sure what I"m supposed to do with this information. You've got the two step process down. Get the request item record, use the sys_id to get the attachment.
Please let me know your expectations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 01:37 PM
Try using:
attachment.addQuery("table_sys_id", current.getValue("sys_id"));
The getValue() method returns the field value as a string. I've found that searching with a sys_id without converting to a string first gives unreliable results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2016 01:56 PM
Hey ,
i tried attachment.addQuery("table_sys_id", current.getValue("sys_id"));
it does not help.
at the point when i make a query the attachment in sys_attachment points to sc_cart_item
i tried gs.sleep(1000)
but this does not help too ( for some reason it will not work till my business rule completes its execution )
confused how to go about this issue