- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 08:26 PM
Hi,
I have created a inbound action to create Request and requested item. Whenever user is attaching any document with email it is not attaching in the respective requested item or request.
I checked the email logs. target is coming as blank.
This is inbound action on Request Table
var cartID = GlideGuid.generate(null);
var cart = new Cart(cartID);
var item = cart.addItem('562790589388b11034dbbb2c5cba');
cart.setVariable(item, 'short_description', email.subject);
cart.setVariable(item, 'description', email.body_html);
var rc = cart.placeOrder();
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
if (ritm.next()) {
ritm.short_description = email.subject;
ritm.description = email.body_html;
ritm.comments = email.body_text;
ritm.contact_type = "email";
ritm.approval = "No Longer Required";
ritm.state = "Work in Progress";
ritm.requested_for = gs.getUserID();
ritm.update();
}
Please help in this.
Thanks,
Samiksha
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 12:46 AM
update and add this line
var cartID = GlideGuid.generate(null);
var cart = new Cart(cartID);
var item = cart.addItem('562790589388b11034dbbb2c5cba');
cart.setVariable(item, 'short_description', email.subject);
cart.setVariable(item, 'description', email.body_html);
var rc = cart.placeOrder();
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', rc.sys_id);
ritm.query();
if (ritm.next()) {
ritm.short_description = email.subject;
ritm.description = email.body_html;
ritm.comments = email.body_text;
ritm.contact_type = "email";
ritm.approval = "No Longer Required";
ritm.state = "Work in Progress";
ritm.requested_for = gs.getUserID();
ritm.update();
// to copy file to REQ use this
GlideSysAttachment.copy('sys_email',sys_email.getUniqueValue(),'sc_request',rc.sys_id.toString());
// to copy file to RITM use this
GlideSysAttachment.copy('sys_email',sys_email.getUniqueValue(),'sc_req_item',ritm.sys_id.toString());
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:27 AM
Hi @Ankur Bawiskar ,
I tested with both code . Attachment is not getting copied to either Request or Requested Item.
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 11:09 PM
Hi @Ankur Bawiskar ,
It is working. Thanks. You always save me.😁
Actually there was a issue in the inbound actions.
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 11:15 PM
Glad to help.
Happy learning.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader