We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

email.subject.indexOf not populating Assignment group through inbound actions

Suman Chatterje
Tera Contributor

Hi All,

I am working on Inbound actions script and as per the test when I am getting the subject carried to the script the subject is getting replicated to the incident but the assignment group is left empty.

function updateINC(inc){
var NC = new GlideRecord('incident_task'); //incident_task
NC.addQuery('incident', inc); 
NC.query(); 
while (NC.next()){ 
NC.short_description = email.subject; 

if (email.subject.indexOf("Closed Complete") >= 0)
{
current.assignment_group = '8a5055c9c61122780043563ef53438e3'; //Hardware 
}
else 
{
current.assignment_group= 'd625dccec0a8016700a222a0f7900d06'; //ServiceDesk
}
current.insert(); 

}

 

Any suggestions please

 

4 REPLIES 4

Allen Andreas
Tera Patron

Hello,

Please use appropriate logging to see what is going on. If no assignment group is getting set, even with an if/else statement, it may be because it never entered your while loop...which could mean the "inc" parameter you passed in to the function is not correct or not a sys_id or something. 

You'd need to review your script and logging for more information.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Wayne Richmond
Tera Guru

Why have you switched to current.assignment_group rather than NC.assignment_group? You also shouldn't need current.insert() if this is new email (rather and reply or forward).

function updateINC(inc){
var NC = new GlideRecord('incident'); //incident_task
NC.addQuery('incident', inc); 
NC.query(); 
while (NC.next()){ 
NC.short_description = email.subject; 

if (email.subject.indexOf("Closed Complete") >= 0)
{
NC.assignment_group = '8a5055c9c61122780043563ef53438e3'; //Hardware 
}
else 
{
NC.assignment_group= 'd625dccec0a8016700a222a0f7900d06'; //ServiceDesk
}

}

 

not working as well

function updateINC(inc){
var NC = new GlideRecord('incident'); //incident_task
NC.addQuery('incident', inc); 
NC.query(); 
while (NC.next()){ 
NC.short_description = email.subject; 

if (email.subject.indexOf("Closed Complete") >= 0)
{
NC.assignment_group = '8a5055c9c61122780043563ef53438e3'; //Hardware 
}
else 
{
NC.assignment_group= 'd625dccec0a8016700a222a0f7900d06'; //ServiceDesk
}

}

not working. Any suggestion please