VMware Cloud Community
Jeremie_R
Contributor
Contributor
Jump to solution

Send failed notification

HI,

is it possible to send a email notification when the workflow finish failed ?

rgds

jeremie

Reply
0 Kudos
1 Solution

Accepted Solutions
Sirry
Enthusiast
Enthusiast
Jump to solution

I highly recommend Burke's approach since there's a lot of nuances that make a general solution will not work perfectly. There is also a high likelihood that if you haven't gotten e-mails or Error Handling to work that you are pretty new to vCO, so that website would be the BEST place to start! I'm sure they have examples of error handling and e-mails, but perhaps not e-mails for error handling...

With that said, I can try to help you along quickly... here are some quick and dirty steps to get something going... you may need the e-mail plugin installed... I'm not sure...

1. For all scripts or places where workflows can fail, bind the Exception variable to a string attribute of your choosing (I will call this ErrorText)

2. Link the exception workflow routes (instead of a normal blue color, link the red color) to a script. Make sure this script has access to ErrorText.

3. Inside the script, use the following (sloppily written) e-mail function:

function send_email(subject, body)

{

  var message = new EmailMessage();  

  message.smtpHost = "xxxx.xxx.xxx.xxx";

  message.fromName = "vCD Admin";

  message.fromAddress = "vCD_Admin@example.com";

  message.toAddress = emailReceivers();

  message.subject = subject;

  message.addMimePart(body,"text/html; charset=UTF-8");  

  System.log( "sending mail from:" + message.fromAddress + ", to:" + message.toAddress );  

  message.sendMessage();

}

send_email("Notice: Workflow Error",ErrorText);

View solution in original post

Reply
0 Kudos
6 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

Sure, sort-of ...

If you have a workflow that has the potential of failing, you should either build in error handling within the workflow and pass the errorCode details to a Send E-mail Notification workflow OR Create another workflow that calls the one that could fail.. Add error handler to this one that sends the e-mail.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Jeremie_R
Contributor
Contributor
Jump to solution

COuld you show me an exemple ?

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

I recommend you start your journey with vCO by reading a few blogs... mine is a good source of detail (http://www.vcoteam.info ), but for your particular question, I would actually recommend you read James Bowling's (@vsential) series of posts here: vCenter Orchestrator: Operation Automate – Part One | vSential. This article series includes exception handling and e-mail notifications Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Sirry
Enthusiast
Enthusiast
Jump to solution

I highly recommend Burke's approach since there's a lot of nuances that make a general solution will not work perfectly. There is also a high likelihood that if you haven't gotten e-mails or Error Handling to work that you are pretty new to vCO, so that website would be the BEST place to start! I'm sure they have examples of error handling and e-mails, but perhaps not e-mails for error handling...

With that said, I can try to help you along quickly... here are some quick and dirty steps to get something going... you may need the e-mail plugin installed... I'm not sure...

1. For all scripts or places where workflows can fail, bind the Exception variable to a string attribute of your choosing (I will call this ErrorText)

2. Link the exception workflow routes (instead of a normal blue color, link the red color) to a script. Make sure this script has access to ErrorText.

3. Inside the script, use the following (sloppily written) e-mail function:

function send_email(subject, body)

{

  var message = new EmailMessage();  

  message.smtpHost = "xxxx.xxx.xxx.xxx";

  message.fromName = "vCD Admin";

  message.fromAddress = "vCD_Admin@example.com";

  message.toAddress = emailReceivers();

  message.subject = subject;

  message.addMimePart(body,"text/html; charset=UTF-8");  

  System.log( "sending mail from:" + message.fromAddress + ", to:" + message.toAddress );  

  message.sendMessage();

}

send_email("Notice: Workflow Error",ErrorText);

Reply
0 Kudos
Jeremie_R
Contributor
Contributor
Jump to solution

MAny thanks for the links and answers.

sorry for all this questions but I'm beginner on vCO and it's not easy but very insterresting.

We are my masters Smiley Wink

Reply
0 Kudos
robrtb12
Enthusiast
Enthusiast
Jump to solution

I know this is already answered but thought I would contribute a workflow monitor I created a while back.  I added the details in the Documents section:

http://communities.vmware.com/docs/DOC-23862

Reply
0 Kudos