Solution Model field not showing value

I have a solution model form with some fields showing only if a checkbox is selected. Selecting the checkbox fires a solution model method. The dataprovider of the field is a variable containing values that I would like to be able to modify in certain circumstances. The problem is that the field never shows the expected value, but it is empty. I am sure, however, that the associated dataprovider variable contains the correct value.

var fldNo = (a  number)
var chkMod = (a checkbox field)
for(var i = 0; i < fldNo; i++)
{
solutionModel.newGlobalVariable('globals','gb_vr_modVal' + i,JSVariable.TEXT);
scopes.globals['gb_vr_modVal' + i] = 'new' + i;
var modValFld = frmCsv.newField(scopes.globals['gb_vr_modVal' + i],JSField.TEXT_FIELD,chkMod.x + 20 + 10,chkMod.y,280,20);
modValFld.name = 'modValFld' + i;
modValFld.visible = false;
modValFld.transparent = false;
}
var chkMeth = "function chkModMeth(oldValue,newValue,event) { if(newValue == 1) { forms['frmCsv']elements['modValFld' + event.getElementName().substring(6)].visible = true; } } 
chkMod.onDataChange = chkMeth;

I tried to change the value of the field dataprovider after making it visible, but same result. And if I do a recreateUI() the field disappear.

I see two problems in there after a quick look:

  • The dataprovider you specify for the new field is wrong. Try to think ‘form designer’ like when using solutionModel. You don’t set the dataprovider’s value in there but it’s name. Try this instead:
var modValFld = frmCsv.newField('scopes.globals.gb_vr_modVal' + i,JSField.TEXT_FIELD,chkMod.x + 20 + 10,chkMod.y,280,20);
  • If chkMod is a JSField, you should use a JSMethod for setting onDataChange. See solutionModel.newGlobalMethod(…) or jsForm.newMethod(…)

Andrei Costescu:
I see two problems in there after a quick look:
… You don’t set the dataprovider’s value in there but it’s name. …

Many thanks. That solved the problem.