UCSD - Email SR Log

Version 3
    Task Name

    This workflow / custom task will e-mail the SR log




    Tested on UCSD

    ComponentsvSphere 5.x
    User Inputs

    Instructions for Regular Workflow Use:

    1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
    2. Unzip the file on your computer. Should end up with a .WFD file.
    3. Log in to UCS Director as a user that has "system-admin" privileges.
    4. Navigate to "Policies-->Orchestration" and click on "Import".
    5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
    6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    8. Click "Submit".
    9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.




    Screen Shot 2017-01-31 at 9.08.28 PM.png




    Different Inputs with severities:


    Screen Shot 2017-01-31 at 9.05.54 PM.png



    Screen Shot 2017-01-31 at 9.06.21 PM.png


    Screen Shot 2017-01-31 at 9.06.30 PM.png


    Screen Shot 2017-01-31 at 9.06.49 PM.png


    Resulting e-mail:


    Screen Shot 2017-01-31 at 9.23.40 PM.png


    Workflow Global Variables:


    Screen Shot 2017-01-31 at 9.08.43 PM.png


    The Custom Task:















    function getMailSettings()


          return ObjStoreHelper.getStore((new MailSettings()).getClass()).getSingleton();






    // Assume the To Email Addres is in the input variable 'Email Address'

    var toEmail = [input.EMAIL];


    var message = new EmailMessageRequest();


    message.setSubject("SR log");






    var srid =  input.SRID;

    logger.addInfo ("SR id : " + srid);

    var srId = parseInt(String(srid));

    logger.addInfo("-------------------------Workflow Errors-----------------------------------"+srid);

    var buffer = "";

    //var sev3Entries = ctxt.getAPI().userAPIGetServiceRequestLogEntries(srId,3);

    var sev3Entries = ctxt.getAPI().userAPIGetServiceRequestLogEntries(srId,input.SEV);

    for (i=0;i<sev3Entries.length;i++){

      if(sev3Entries[i].getSeverity() == 0){

      logger.addInfo (sev3Entries[i].getMessage());

      buffer = buffer + sev3Entries[i].getMessage() + "<br>";



    logger.addInfo("-------------------------Workflow Errors-----------------------------------"+srid);



    var body = "<head><style type='text/css'>";



    // Specify CSS for the report

    body = body + "table { font-family: Verdana, Geneva, sans-serif; font-size: 12px; border: thin solid #039; border-spacing: 0; background: #ffffff; } ";



    body = body + " th { background-color: #6699FF; color: white; font-family: Verdana, Geneva, sans-serif; font-size: 10px; font-weight: bold; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; } ";


    body = body + " td { font-family: Verdana, Geneva, sans-serif; font-size: 10px; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; background: #ffffff; }";


    body = body + "</style></head>";

    body = body+ "<body><h1>SR Log " + input.SRID + "</h1><br>" + buffer.toString();




    logger.addInfo("Sending email");



    // Now, send the report via email. First parameter is just a label used in the

    // internal logs

    MailManager.sendEmail("SR log", getMailSettings(), message);