12-28-2015 09:17 AM - edited 03-01-2019 06:39 AM
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.
Code snippet 1:
<Cloupia:ReportScript>
importPackage(com.cloupia.service.cIM.inframgr.customactions);
</Cloupia:ReportScript>
Code snippet 2:
if (def != null && def != "")
{
var inputs = CustomActionUtil.getWorkflowInputFieldDefinitions(def.getId());
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();
}
}
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);
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();
}
}
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:
How do you also print values provided by the user?
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);
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();
}
}
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
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: