When the RITM is generated through inbound email action related sc task and sla is not triggering

sirishap1638674
Tera Contributor

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?

9 REPLIES 9

Runjay Patel
Giga Sage

Hi @sirishap1638674 ,

 

SC Task will generate based on flow configured on that item, Did try to submit from portal and check whether sc task are getting generated or not? If from portal also happening the same then check flow which you have attached to the item.

 

-------------------------------------------------------------------------

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

-------------------------------------------------------------------------

sirishap1638674
Tera Contributor

Hi @Runjay Patel 

 

Thanks for responding

 

But when i am submitting through portal the sctask and sla are triggering .

Through inbound action it is not triggering

Hi @sirishap1638674 ,

 

Share the screenshot or code of inbound action.

 

sirishap1638674
Tera Contributor
(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
ritm.insert();


    var task = new GlideRecord('sc_task');
    task.initialize();
    task.cat_item = '26cbeef24795061033ba5e5fe16d4314';
    task.short_description = ritm.short_description || "Task for " + ritm.short_description;
    task.assignment_group = 'c71fa3a1c38102506625954d050131d9';  
    task.insert();  

   
    var sla = new GlideRecord('contract_sla');
    sla.addQuery('contract', ritm.request);  
    sla.query();
    if (sla.next()) {
        var slaTask = new GlideRecord('sla_task');
        slaTask.initialize();
        slaTask.sla = sla.sys_id;
        slaTask.target = ritm.sys_id;
        slaTask.insert();
    }

})(current, event, email, logger, classifier);