Solution Model: 2 comboboxes, different behavior

There is something I don’t understand, but I am quite sure there is some oversight by me.

In a solution model form I have two comboboxes with identical code.
1st combobox (repCombo)

var vl_repIns = solutionModel.newValueList('vl_repIns' + application.getTimeStamp(), JSValueList.CUSTOM_VALUES);
	vl_repIns.customValues = 'Replace|REPLACE\nInsert|INSERT';
	var repIns = frmCsv.newVariable('repIns',JSVariable.TEXT);
	
	var repCombo = frmCsv.newField(repIns,JSField.COMBOBOX,450,300,220,20);
	repCombo.valuelist = vl_repIns;
	repCombo.transparent = true;
	repCombo.editable = false;

2nd combobox (testCombo)

var vltest1 = solutionModel.newValueList('testcombovl' + application.getTimeStamp(),JSValueList.CUSTOM_VALUES);
	vltest1.customValues = 'Do Not Import|@dummy\nImport|import'
	var testVar = frmCsv.newVariable('test_csv',JSVariable.TEXT);
		
	var testCombo = frmCsv.newField(testVar,JSField.COMBOBOX,450,50,220,20);
	testCombo.valuelist = vltest1;
	testCombo.transparent = true;
	testCombo.editable = false;

I want to display an initial value when the form is shown. This is the method:
var onShowFrmCsv = frmCsv.newMethod(“function onShow(firstShow,event) { repIns = ‘REPLACE’; testVar = ‘@dummy’; }”);

Apparently both comboboxes should display a value (‘Replace’ and ‘Do Not Import’ respectively). But only one is shown (Replace), the other is blank. Any idea?

Hi,

Actually the problem is you have assigned the value to be shown first to jsVariable (testVar) in onShow method in place of the variable name(test_csv). Please change it to ‘test_csv’ and it is working.

Hope this will solve your problem.

Thanks
Sovan

Hi Sovan,
thank you for your help. I played with different combinations of variable, variable name and data provider and I found that normally the data provider can be either the variable itself or the variable name.

In this scenario var test_Var = frmCsv.newVariable('testVar',JSVariable.TEXT); the data provider can be both test_Var (the variable) or ‘testVar’ (the name) and both these statements seem to work var testCombo = frmCsv.newField(test_Var,JSField.COMBOBOX,50,50,220,20); or ```
var testCombo = frmCsv.newField(‘testVar’,JSField.COMBOBOX,50,50,220,20);

BUT, using variable **testVar** instead of **test_Var** (without the underscore) the method doesn't work any more either with the variable name as data provider 

var testVar = frmCsv.newVariable(‘test_Var’,JSVariable.TEXT);
var testCombo = frmCsv.newField(‘test_Var’,JSField.COMBOBOX,50,50,220,20);


or with the variable itself ```
var testCombo = frmCsv.newField(testVar,JSField.COMBOBOX,50,50,220,20);

I don’t understand why. A naming problem? Why?

Hi,

var testVar = frmCsv.newVariable('test_csv',JSVariable.TEXT);
var onShowFrmCsv = frmCsv.newMethod("function onShow(firstShow,event) { repIns = 'REPLACE'; testVar = '@dummy'; }");

Here you have created a variable with name ‘test_csv’ but in onShow method you are assigning the default value(@dummy) to ‘testVar’ which do not exist.

which should be:

var onShowFrmCsv = frmCsv.newMethod("function onShow(firstShow,event) { repIns = 'REPLACE'; test_csv = '@dummy'; }");

Thanks
Sovan Misra
http://www.mindfiresolutions.com