cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2485
Views
1
Helpful
3
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee

Posted for Logesh Kandasamy. Thank you very much.

This is an example on how to update an e-mail template with workflow input from the user.

The below 2 part of the code snippets to be placed in the Body section of the Email template. Try like as below. Please let us know if any clarification.

  1. 1.     Place the below code before the HTML <head> tag element


Unknown.jpeg


            Code snippet 1:

<Cloupia:ReportScript>

importPackage(com.cloupia.service.cIM.inframgr.customactions);

</Cloupia:ReportScript>

  1. 2.     Place the below code snippet before the HTML Body tag Closure

Unknown-1.jpeg

Code snippet 2:

if (def != null && def != "")

{

var inputs = CustomActionUtil.getWorkflowInputFieldDefinitions(def.getId());

  • out.println("<p>Workflow Name:</p>"+ def.getName());
  • out.println("<table class='c1' width=85% cellpadding=5 border=2 bgcolor='" + "#E3EFFE" + "'>");
  • out.println("<tr><th>Label</th><th>Name</th><th>Type</th></tr>");

for (var i=0;i<inputs.size();i++){

var inputDef = inputs.get(i);

var desc = inputDef.getDescription();

var label = inputDef.getLabel();

var name = inputDef.getName();

var type = inputDef.getType();

  • out.println("<tr><td>"+label +"</td><td>"+name+"</td><td>"+type+"</td></tr>");

}

  • out.println("</table>");

}

Unknown-2.jpeg

The following code snippet will result in below picture:

if (def != null && def != "")

{

var inputs = CustomActionUtil.getWorkflowInputFieldDefinitions(def.getId());

  importPackage(com.cloupia.service.cIM.inframgr.customactions);

  var srId = request.getDataObject().getObjects().getServcieRequest() .getInputSetId();

  var ListOfWorkflowInputValue = CustomActionUtil.getWorkflowInputValues(srId);

  •   out.println("<p>Workflow Name:</p>"+ def.getName());
  •   out.println("<table class='c1' width=85% cellpadding=5 border=2 bgcolor='" + "#E3EFFE" + "'>");
  •   out.println("<tr><th>Label</th><th>Value</th><th>Name</th><th>Type</th></tr>");

for (var i=0;i<inputs.size();i++){

var inputDef = inputs.get(i);

var desc = inputDef.getDescription();

var label = inputDef.getLabel();

var name = inputDef.getName();

var type = inputDef.getType();

  var value = ListOfWorkflowInputValue.get(i).getInputFldValue();

  •   out.println("<tr><td>"+label +"</td><td>"+value +"</td><td>"+name+"</td><td>"+type+"</td></tr>");

}

  •   out.println("</table>");

}


Screen Shot 2016-11-15 at 9.10.43 AM.png

I combined version 1 and version 2 to result in version3. 


And a big thank you to Tejeswar Sahu

Attached is the version that prints this version:

Screen Shot 2016-11-15 at 9.12.13 AM.png

Comments

How do you also print values provided by the user?

Orf Gelbrich
Cisco Employee
Cisco Employee

try this code..

if (def != null && def != "")

{

var inputs = CustomActionUtil.getWorkflowInputFieldDefinitions(def.getId());

  importPackage(com.cloupia.service.cIM.inframgr.customactions);

  var srId = request.getDataObject().getObjects().getServcieRequest() .getInputSetId();

  var ListOfWorkflowInputValue = CustomActionUtil.getWorkflowInputValues(srId);

  •   out.println("<p>Workflow Name:</p>"+ def.getName());
  •   out.println("<table class='c1' width=85% cellpadding=5 border=2 bgcolor='" + "#E3EFFE" + "'>");
  •   out.println("<tr><th>Label</th><th>Value</th><th>Name</th><th>Type</th></tr>");

for (var i=0;i<inputs.size();i++){

var inputDef = inputs.get(i);

var desc = inputDef.getDescription();

var label = inputDef.getLabel();

var name = inputDef.getName();

var type = inputDef.getType();

  var value = ListOfWorkflowInputValue.get(i).getInputFldValue();

  •   out.println("<tr><td>"+label +"</td><td>"+value +"</td><td>"+name+"</td><td>"+type+"</td></tr>");

}

  •   out.println("</table>");

}

Hello,

I think this line:

var value = ListOfWorkflowInputValue.get(i).getInputFldValue();

will not work here, as lists "inputs" and "ListOfWorkflowInputValue" have different indexing (numbering), and wrong values are shown by each label. I used the following code:

  var inputs = CustomActionUtil.getWorkflowInputFieldDefinitions(def.getId());

  var ListOfWorkflowInputValue = CustomActionUtil.getWorkflowInputValues(serviceRequest);

  var valueHash = []

  for (var count = 0; count < ListOfWorkflowInputValue.size(); count++)

  {

    var valueId = ListOfWorkflowInputValue.get(count).getInputFldId();

    var value = ListOfWorkflowInputValue.get(count).getInputFldValue();

    valueHash[valueId] = value;

  }

 

  out.println("<table cellpadding='5' border='1'>");

  out.println("<tr><th>Label</th><th>Value</th><th>Type</th><th>Description</th></tr>");

  for (var i = 0; i < inputs.size(); i++)

  {

    var inputDef = inputs.get(i);

    var desc = inputDef.getDescription();

    var label = inputDef.getLabel();

    var type = inputDef.getType();

    var name = inputDef.getName();

    var value = valueHash[name];

    out.println("<tr><td>"+label +"</td><td>"+value+"</td><td>"+type+"</td><td>"+desc+"</td></tr>");

  }

  out.println("</table>");

Cheers,

Krzysztof

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links