Hello everyone,
I want to export some variables to excel file (screenshot has been attached), by using the camudna service task (screenshot has been attached), how can define the JS file into BPMN/ Service Task.
In addtion, how can added new rows of values for every variable with out detele the current values, which mean, every iteration I want to add a new row values without delete/ doing changing in values that has been added in the previous iterations.
Thank You,
var Files = Java.type(‘java.nio.file.Files’)
var Paths = Java.type(‘java.nio.file.Paths’)
var CSVPrinter = Java.type(‘org.apache.commons.csv.CSVPrinter’)
var CSVFormat = Java.type(‘org.apache.commons.csv.CSVFormat’)
var StandardOpenOption = Java.type(‘java.nio.file.StandardOpenOption’)
var Customer_Name = execution.getVariable(‘CustomerName’)
var Customer_Credit = execution.getVariable(‘CustomerCredit’)
var Customer_Type = execution.getVariable(‘CustomerType’)
var Maximum_Shipping_Weight = execution.getVariable(‘MaximumShippingWeight’)
var csvPath = “C:/Users/M.Sc Project.DESKTOP-2QLSO86/OneDrive/Shipping Order Camunda Run Final Verson/Output/output.csv”;
var writer = Files.newBufferedWriter(Paths.get(csvPath), StandardOpenOption.APPEND);
// Example of adding a header row.
// Make sure to add logic for detecting header row and not adding the header row on subsequent appends
// Simple workaround is to just make sure the first row is always included in your CSV file.
var csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(“Customer_Name”, “Customer_Credit”, “Customer_Type”, “Maximum_Shipping_Weight”));
//var csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT);
// If you have multiple records to add to the csv,
// you can loop through this line:
csvPrinter.printRecord(Customer_Name, Customer_Credit, Customer_Type, Maximum_Shipping_Weight);
csvPrinter.flush();
,