Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi,
System.out.println("isChecked: " + isChecked);
How about you try placing the line above right after var isChecked = row.getProperty("cancelar");
to see if the checkbox state is correctly obtained.
Now, for the conditions not behaving as expected:
can_aprovisionada > 0 && isChecked == true
: Verify that can_aprovisionada
is greater than 0 when you expect it to be and isChecked
is true when the checkbox is checked. You might also print out can_aprovisionada
and isChecked
to ensure they have the expected values.
can_registrada == 0 && isChecked == true
: Similar to above, ensure that can_registrada
is indeed 0 when expected and isChecked
reflects the checkbox state.
Let me know how it goes.
Hi John Smith finally I found the way to manage this type of values, this is the piece of code:
Thanks for Your Ilustration, I would like to ask you where I can see teh output fo this
instruccion System.out.println("isChecked for this row: " + isChecked); if I'm working on cloud version
boolean isChecked = false;
for (FormRow row : rows) {
try {
// ... your existing code ...
// Get the value of the "cancelar" checkbox
isChecked = Boolean.parseBoolean(row.getProperty("cancelar"));
System.out.println("isChecked for this row: " + isChecked);
// ... your existing code ...
} catch (Exception e) {}
}
Hi Experts,
I´m needing validate the value in a checkbox located in a spreadsheet, anybody have an example about the code lines to do it?
I'm using this code currectly but it don't work, I'm remark the lines specifically with the problem.
I have tried saving the value in an String and later in an Boolean variable but I don't achieve do the evaluation.
public boolean validate(Element element, FormRowSet rows, FormData formData) {
boolean result = true;
if (rows != null && !rows.isEmpty()) {
int total = 0;
String haycancelacion = "No";
//Sum the values from column "amount"
for (FormRow row : rows) {
try {
int can_registrada = Integer.parseInt(row.getProperty("can_movimiento"));
int can_pedida = Integer.parseInt(row.getProperty("cantidad"));
int can_aprovisionada = Integer.parseInt(row.getProperty("cant_aprov"));
total += can_registrada;
var isChecked = row.getProperty("cancelar"); //Remark "This is the field Type Checkbox in the spreadsheet .
cantidad_maxima = (can_pedida - can_aprovisionada);
if (can_registrada > cantidad_maxima) {
String id = FormUtil.getElementParameterName(element);
formData.addFormError(id, "La cantidad aprovisionada no puede ser mayor a la cantidad solicitada menos la cantidad aprovisionada!!!! ");
result = false;
}
else {
//This is the first evaluation that I'm trying to do and don't work, the evaluation is bypassed (of course does not by the value of can_aprovisionada)
if (can_aprovisionada > 0 && isChecked == true) {
String id = FormUtil.getElementParameterName(element);
formData.addFormError(id, "No puede cancelar un requerimiento previamente aprovisionado!!!! ");
result = false;
}
//This is the second evaluation that I'm trying to do and don't work, the evaluation is bypassed (of course does not by the value of can_registrada)
else if (can_registrada == 0 && isChecked == true){
haycancelacion = "Si";
}
}
} catch (Exception e) { LogUtil.error("Sample app - Bulk Create Users form", e, "Store user error!!"); }
}
if (total == 0 && haycancelacion.equals("No")) {
String id = FormUtil.getElementParameterName(element);
formData.addFormError(id, "Aprovisione alguno de los artículos antes de continuar!!!!" + isChecked);
result = false;
}
}
return result;
}
//call validate method with injected variable
return validate(element, rows, formData);