Inbound Email Action - Target is empty and message 'did not create or update incident using current'

Mario25
Giga Expert

Hello, 

I have an inbound action rule that is properly finding and updating my incident but two things are missing. 

1 the target is empty on the email log.
2. the email doesn't get attached to the incident as email received.

///----------------------------------------------------------

 gs.include('validators');

var incNum = email.subject.substring(32,42); //get incident number from email subject

if((email.subject.indexOf("Received") > -1) ) 
{
var incident_num_rec = new GlideRecord('incident'); 
incident_num_rec.addQuery();
incident_num_rec.addQuery('number', incNum); 
incident_num_rec.query(); 
if(incident_num_rec.next())
{
incident_num_rec.work_notes = "An email was received from Ricoh Support and forwarded to this ticket";
incident_num_rec.comments = "A Ricoh support call has been opened";
incident_num_rec.u_fournisseur_externe = "Ricoh";
incident_num_rec.state = 3;
incident_num_rec.hold_reason = 4;
incident_num_rec.update();
}
}

else
{
state = stop_processing;

///----------------------------------------------------------

 

Any help would be appreciated.

Thanks,

MjF

1 ACCEPTED SOLUTION

After reviewing a dozen times I realized you wanted my gr.  Updated the lines:

sys_email.target_table = "incident";
sys_email.instance = incident_num_rec.sys_id;
sys_email.update();

and it DOES ATTACH MY EMAIL.

Thank you @Ashutosh Munot .

MjF

View solution in original post

6 REPLIES 6

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

Can you try this line of code in your if loop:

sys_email.target_table = "incident";
sys_email.instance = gr.sys_id;
sys_email.update();


Thanks,
Ashutosh

HI,

If you have a ticket number in subject line then it should automatically set that.

Thanks,
Ashutosh

Hey, that's what I thought, but its not capturing the number from subject on these emails.  Thats why I did the 'email.subject.substring(32,42)' to hard code it.

Hey, 

I added those 3 lines after 'incident_num_rec.update();' and it produced the same thing.  Updated the ticket fine but no email received and now the target is Null instead of (empty).

Thanks,
MjF