- 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 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 12:57 AM
Hi @Ankur Bawiskar ,
Thank you for reply.
I added the code in the inbound action. Still not getting attachment.
This is email log. In the email log attachment is there but in the RITM it is not coping.
Thanks,
Samiksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:04 AM
Hi @Ankur Bawiskar ,
I search this article.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0547763
I am not sure if this resolve my issue but how
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:15 AM
the line I shared should work fine.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader