Problem with changing global through combobox

I have a form that is being created on the fly through the solutionModel. On this form there is just a combobox and a button:

//create the form
var newForm = solutionModel.newForm('newform',controller.getServerName(),controller.getTableName(),'Style',false,400,400);

//create the combobox
var comboboxFld = newProductForm.newField(globals.variationTypeValue,SM_DISPLAYTYPE.COMBOBOX,180,100,160,200);
comboboxFld.valuelist = solutionModel.getValueList('variation_types');

//create new form method
var newScript = "function testValueBtn() {";
newScript += "	application.output(globals.variationTypeValue);";
newScript += "	};";
var newMethod = newForm.newFormMethod(newScript);

//create button with new method attached
var newBtn = newForm.newButton('Test',180,380,120,20,newMethod);

In the startup script I’ve declared the global ‘variationTypeValue’ with a standard value of ‘1’.
No matter what I select in the combobox, when pushing the button the application output is always ‘1.0’.

Am I overseeing something or doing anything wrong in the above code?

:oops: Ok… I thought I tried everything already…but… :D I overlooked the following method:

comboboxFld.dataProviderID = 'globals.variationTypeValue';

I really thought that naming the dataprovider in .newField() was sufficient.

First he 1 argument of the newField is not the dataprovider but the name
second:

newProductForm.newField(globals.variationTypeValue,SM_DISPLAYTYPE.COMBOBOX,180,100,160,200);

will create a field with the name of the value the global now has, not the name “globals.variationTypeValue” itself.

Ah ok! I got confused by the tooltip of the newField method:

newProductForm.newField(dataprovidername/jsvariable,displaytype,x,y,width,height)

‘dataprovidername/jsvariable’ made me think that this was the place to attach the dataprovider, I see that this is just the name for the field.

ahh stupid my mistake
it is the dataprovider (you have to set the name later on if you want to access it later on)

Your initial problem is that you didnt have globals.xxxx between quotes (or that it isnt a JSVariable)