When the RITM is generated through inbound email action related sc task and sla is not triggering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 04:41 AM
I have created a script for an inbound email action to generate an RITM. but only RITM is generating and related SC task and SLA is not triggering . can someone please help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 06:38 AM
Hi @sirishap1638674 ,
Why are you gliding to create record you can simply use cart api to create the ritm.
check this blog for creating ritm using cart api: https://servicenowwithrunjay.com/create-ritm-using-cart-api-in-servicenow/
Anyway Use below code.
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Create a new RITM for the "General Catalog" catalog item
var ritm = new GlideRecord('sc_req_item');
ritm.initialize();
ritm.cat_item = '26cbeef24795061033ba5e5fe16d4314'; // Link to "General Catalog" using the known sys_id
ritm.short_description = email.subject || "New Request"; // Default to email subject or "New Request"
ritm.description = email.body_text || "Details not provided"; // Default to email body or placeholder
ritm.requested_for = email.origemail; // Set the requester from email's original sender
ritm.assignment_group = 'c71fa3a1c38102506625954d050131d9'; // Set the assignment group using the sys_id
ritm.state = 1; // "New" state
var sysid = ritm.insert();
var task = new GlideRecord('sc_task');
task.initialize();
task.cat_item = '26cbeef24795061033ba5e5fe16d4314';
task.request_item= sysid ;
task.short_description = ritm.short_description || "Task for " + ritm.short_description;
task.assignment_group = 'c71fa3a1c38102506625954d050131d9';
task.insert();
})(current, event, email, logger, classifier);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 06:46 AM
Thanks but why is it not triggering by default ?
i mean without scripting by default the sla and sctask should trigger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 07:33 AM
Yes it should trigger once you cart api to submit the ritm. do not do glide record.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 07:37 AM
ok, But how do i do that please i am not sure of that .
please give me code including cart api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 07:43 AM
Hi @sirishap1638674 ,
I had given you link in above chat , if you could have gone through then you would have find out. Its very easy.
anyway use below code
var id = GlideGuid.generate(null);
var cart = new Cart(id);
var item = cart.addItem('26cbeef24795061033ba5e5fe16d4314');
cart.setVariable(item,'short_description ','New Request');
cart.setVariable(item,'description ','New Request');
var request = cart.placeOrder();
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------