VMware Cloud Community
TomBrady5Rings
Contributor
Contributor

Customizing emails

I am just using the workflow that sends out an email. It is the one built into Orchestrator. Is there a way to use Variables in the subject or the content wizard? So I could send out an email that says Your new vm $VMName is ready for example will send out an email that says Your new vm dpoctestemail is ready.

0 Kudos
2 Replies
KRAEMS
Enthusiast
Enthusiast

Hi Tom,

Yes, variables and strings can be introduced into both subject and content of the email.  These variables can be (but are not necessarily limited to) either input parameters or attributes of the workflow - so long as they are bound to the scriptable task element of the workflow, as well as variables set within the scriptable task element itself.  For myself, I scripted (with help - I am hardly a javascript expert) an email notification system that emails out status updates as software installation proceeds:

- The VM named 'X' has been cloned

- The VM named 'X' has been configured

- 'application_name_here' has been installed on a virtual machine named 'X'

and so on...

In my case, I used javascript to map the desired email subject and content strings in concert with an index I then increment with each pass within a cloned copy of orchestrators original send notification workflow... Doing so allows me to send out alerts as various milestones are accomplished, using the same 'send notification' child workflow called at each point through the creation process.  Doing so drastically reduces duplication of both workflow elements, as well as input parameters/attributes with the desired custom messaging.

KRAEMS

0 Kudos
BillStreet00
Enthusiast
Enthusiast

I created a WF that creates a custom HTML message, evaluate whether to send the message and then finally send the message.  The decision to send the message is based on changes such as "VMPSMasterWorkflow32.MachineActivated".  By far the largest piece of code was creating the message body with HTML.

Here is what my case statements look like, they do the heavy lifting of creating the message.  Just send the "message" variable to the "Send Notification" WF.

case 'VMPSMasterWorkflow32.Disposing':

System.log("Setting the email")

var emailRequired="true"

var subject = "Your request for " + payload.get("blueprintName") + "STATUS Update." 

System.log("Building content")

         content = {The HTML code for the message content}

 

I added quite a bit of information in my emails. I have a screenshot of what the email looks like attached.

case 'VMPSMasterWorkflow32.Disposing':
System.log("Setting the email")
var emailRequired="true"
var subject = "Your request for " + payload.get("blueprintName") + "STATUS Update." 
System.log("Building content")
0 Kudos