Problem with Dataset

Questions, tips and tricks and techniques for scripting in Servoy

Problem with Dataset

Postby tommygill » Thu Aug 26, 2010 3:28 pm

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

Code: Select all
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.
Tom

Mac OS X 10.6.7
Servoy version 5.2.0 -build 997
Java Version 1.6.0_20
User avatar
tommygill
 
Posts: 110
Joined: Thu Jan 27, 2005 1:38 pm
Location: Columbus, Indiana, USA

Re: Problem with Dataset

Postby ROCLASI » Thu Aug 26, 2010 3:47 pm

Hi Tom,

Is this method on a form or is it a global method ?
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Problem with Dataset

Postby tommygill » Thu Aug 26, 2010 4:00 pm

It is a global method
Tom

Mac OS X 10.6.7
Servoy version 5.2.0 -build 997
Java Version 1.6.0_20
User avatar
tommygill
 
Posts: 110
Joined: Thu Jan 27, 2005 1:38 pm
Location: Columbus, Indiana, USA

Re: Problem with Dataset

Postby ROCLASI » Thu Aug 26, 2010 4:07 pm

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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Problem with Dataset

Postby tommygill » Thu Aug 26, 2010 4:44 pm

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.
Tom

Mac OS X 10.6.7
Servoy version 5.2.0 -build 997
Java Version 1.6.0_20
User avatar
tommygill
 
Posts: 110
Joined: Thu Jan 27, 2005 1:38 pm
Location: Columbus, Indiana, USA

Re: Problem with Dataset

Postby tommygill » Thu Aug 26, 2010 9:40 pm

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.
Tom

Mac OS X 10.6.7
Servoy version 5.2.0 -build 997
Java Version 1.6.0_20
User avatar
tommygill
 
Posts: 110
Joined: Thu Jan 27, 2005 1:38 pm
Location: Columbus, Indiana, USA

Re: Problem with Dataset

Postby mboegem » Thu Aug 26, 2010 10:18 pm

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
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Problem with Dataset

Postby tommygill » Fri Aug 27, 2010 8:00 pm

Thanks Marc

I will see if I can get something to work.
Tom

Mac OS X 10.6.7
Servoy version 5.2.0 -build 997
Java Version 1.6.0_20
User avatar
tommygill
 
Posts: 110
Joined: Thu Jan 27, 2005 1:38 pm
Location: Columbus, Indiana, USA


Return to Methods

Who is online

Users browsing this forum: No registered users and 13 guests