Problem with Dataset

Hi All
I have the following method that I’m trying to use to populate a Valuelist.

function onAction_test(event) {
	var query = "SELECT state_name FROM states WHERE state_country = ?";
	var args = new Array();
	args[0] = forms.Names.name_address_country;
	var dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), query, args, -1);
}

This method keeps throwing this error.

ReferenceError: “controller” is not defined.

I have other methods that use the same getDataSetByQuey code that works properly. I even placed this method in a plain button but it keeps throwing the error.

All help greatly appreciated.

Hi Tom,

Is this method on a form or is it a global method ?

It is a global method

Hi Tom,

Then that is your problem. A global method is not in the context of a form so it doesn’t have a controller.
What you can use is currentcontroller but keep in mind that this is the controller of the top most form. So it won’t use the controller from any forms loaded in tabpanels.

Hope this helps.

Thanks Robert.

I did forget about the “currentcontroller”.
After making sure that the states valuelist has the global method assigned and the “state” field, which is a typeahead, has the states valuelixt assigned, it still does not produce the valuelist with all the states in it.

Hi All

OK. Here is what I am trying to accomplish. I have a state field in which I store the two digit abbreviation for the state. I want to be able to popup a menu(similar to a valuelist) from which the user can choose a state. I want to show the state abbreviation and the state name in the popup menu. I only want the abbreviation to be stored in the db and I only want the abbreviation to show in the field on the form. I don’t think this can be done with a valuelist because whatever shows on the valuelist is what is displayed in the field on the form. I should be able to do this with a popup menu but i don’t know how to populate a menu with a dataset.

All help is greatly appreciated.

Hi Tom,

with a bit of workaround it should be doable.
If you use the onFocus / onFocusLost events of this field and populate a dedicated valuelist assigned to this particular field, you could just switch whatever you want.

Hope this helps

Thanks Marc

I will see if I can get something to work.