Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
If you want to assign one workflow variable to another workflow variables then you can use workflow variable update tool instead of writing the java code
i build a process, and ihave intilize a workflow variables as this (var1: contain values which user selected from multi selected box , var2: its a hidden field for storing the first value from var1(have default value 'empty')
so i write a java code and put it inside a tool but it does not work , not storing the first value from the var1 to var 2
this is the code
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.service.FormService;
import org.joget.commons.util.LogUtil;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class MultiSelectHandler {
public void handleMultiSelectField(FormData formData, FormService formService) {
// Get the multi-select field value from form data
String multiSelectFieldName = "approversList";
String fieldValue = formData.getFieldValue(multiSelectFieldName);
if (fieldValue != null && !fieldValue.isEmpty()) {
// Split the field value by semicolons to get a list of selected values
List<String> selectedValues = Arrays.asList(fieldValue.split(";"));
if (!selectedValues.isEmpty()) {
// Get the first selected value
String firstSelectedValue = selectedValues.get(0);
// Store or use the first selected value as needed
// For example, set it as a new value in the form data
formData.getFieldValues().put("firstSelectedApprover", firstSelectedValue);
// Optionally, log or further process the firstSelectedValue
LogUtil.info(MultiSelectHandler.class.getName(), "First Selected Approver: " + firstSelectedValue);
} else {
LogUtil.info(MultiSelectHandler.class.getName(), "No values found after splitting.");
}
} else {
LogUtil.info(MultiSelectHandler.class.getName(), "No values found in approversList.");
}
}
}