I have programatically created a few checkboxes using SM, and added them to an SM-generated form. At the same time I have created a formVariable (also thru SM) and set that formVariable to be the dp for a checkbox - meaning 1 checkbox for every 1 formVariable. The formVariable is of type INTEGER and has a default value of 0.
There is an onAction method attached to each checkbox which toggles the value of the formVariable from 0 to 1. I tested the value of the formVariable for each checkbox before the onAction method fired and also after it fired: Before it was 0 (the default) and after it was 1. So in my thinking, after the value of the formVariable, which is the dp for the checkbox, changes from 0 to 1, the checkbox should show checked. Am I wrong? Am I missing something?
jbader:
There is an onAction method attached to each checkbox which toggles the value of the formVariable from 0 to 1.
You don’t need an onAction method to do that, it’s standard behavior for a checkbox field, just remove the method from the onAction event and be sure to not use any valuelist with that field, when no valuelist is used on checkboxes they default to 0 or NULL when unchecked and 1 when checked, no need for extra code.
The onAction may not be needed to flip the bit (0->1), but are you saying that a checkbox won’t check if it has an onAction event attached to it? That does not seem to be inline with my experience.
I don’t need the onAction method to flip the bit necessarily, but I do need the onAction method attached to the checkbox, because it does important things. If I comment out the part that flips the bit, the checkbox still does not check. I will try removing the onAction all together and seeing if that helps, but that kinda defeats the purpose for me.
Below is a simple script that creates a new SM form with SM checkboxes, each with their own SM var. The checkboxes won’t check (be it for onDataChange or onAction, or even if I leave off the event attachment all together). I must be missing something.
function createSMFormWithSMCheckboxesAndSMVars()
{
var mySMForm = solutionModel.newForm('checkbox_woes', currentcontroller.getServerName(), 'customer', null, false, 130, 250);
var current_var = null;
var current_checkbox = null;
// Add 10 SM checkboxes, each with their own corresponding SM form var
for(i = 0; i < 10; i++) {
current_var = mySMForm.newFormVariable('v' + i,SM_VARIABLETYPE.INTEGER);
current_var.defaultValue = 0; // Does this actually initialize the new var to 0 or not?
current_checkbox = mySMForm.newCheck(current_var,10,(20 * (i + 1)),30,20); // I think param 1 should be var obj and not a string name?
current_checkbox.setOnDataChangeMethod(globals.shouldWork);
}
application.showFormInDialog(forms[mySMForm.name]);
}
I am uploading a 4.1 RC1 sample solution. Hopefully someone out there can see what the issues is. My hope is I am overlooking something simple, although if that is not the case I will file as a bug.