java tool process
java not running inside the tool process why ?
here the code the approversList stored from multiselect box multiple values and the firstSelectedValue intilized at the same form with initial value
i want to store the first approvers inside the firstSelectedValue variable, whats the wrong here, please ?
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.");
}
}
}