Send a notification on Inbound email action

Jyoti36
Mega Expert

I have created an Inbound action on incident table.

Where, its matching the condition on incident, if the incident is found, then do the updates from inbound. This works fine.

Now, I just want to sent an email notification if the incident is not found. I was just wondering the following solution will work or not:

1. I am thinking of registering a new event and then using that in my else condition of the same inbound action,

2. which will then fire the notification. Is that going to work without any errors?

Please suggest if this is the best or do we have any other best option as well.

Thanks in advance!

Cheers!

23 REPLIES 23

The only problem with my code is, it is always executing the "gs.eventQueue("task.no.externalref.found", targetRec, email.body.external_reference, email.body_text);" even if I use the opposite of the IF and is not entering the else (highlighted in bold) at all.


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


if (targetRec.next()) {


  if (targetRec.abc_reference_number != "" || targetRec.abc_reference_number != "email.body.external_reference")//This is working even if the reference number is empty


  {


  gs.eventQueue("task.no.externalref.found", targetRec, email.body.external_reference, email.body_text);


  }


  else {


  targetRec.abc_reference_number = email.body.external_reference;


  var worknote = email.body.worknotes;


  targetRec.work_notes = worknote.replace(/<cr>/g, "\n");


  //targetRec.work_notes = String(email.body.worknotes);


  if(status == "Resolved" || status == "Closed")


  {


  targetRec.state = 6;


  targetRec.u_cause_code="Unknown";


  targetRec.u_resolution_code="Resolved By Third Party";


  targetRec.u_actual_affected_ci= targetRec.u_technical_service;


  }


  else {


  targetRec.state =status;


  }


  targetRec.update();


  }


Is the column name correct abc_reference_number?


Yes, I have changed the name here coz of security concerns.



Rest below part is working only, may be some braces issue or I have tried not using it as a string. Still no luck...



if (targetRec.abc_reference_number != '' || targetRec.abc_reference_number != 'email.body.external_reference')//This is working even if the reference number is empty


  {


  gs.eventQueue("task.no.externalref.found", targetRec, email.body.external_reference, email.body_text);


  }


It's firing the notification all the time.... nothing else is working.


Put few logs statement to debug