How to get field value of Solution Model Field

Questions and answers for designing and implementing forms in Servoy

How to get field value of Solution Model Field

Postby hareendra » Wed Jan 29, 2014 11:48 am

Hi All,

I have a form (Table View) in my solution:
var _form1 = solutionModel.getForm('frm_form1');

Then I added a field with the SM:
var _field1 = _form1.newTextField('person_name', 100, 100, 140, 20);

(person_name is a column in a dataset)

Then I gave the field a name:
_field1.name = 'person_name';

Then I need to get the person_name of the selected record of the form.

I tried doing:
application.output(forms.frm_form1.foundset.person_name)

I get a null value.
Can someone help me with this?

Thanks in advance!

Regards,
Hareendra
hareendra
 
Posts: 98
Joined: Wed Sep 17, 2008 11:41 am

Re: How to get field value of Solution Model Field

Postby mboegem » Wed Jan 29, 2014 2:36 pm

hareendra wrote:Then I need to get the person_name of the selected record of the form.

I tried doing:
application.output(forms.frm_form1.foundset.person_name)

I get a null value.
Can someone help me with this?


Are your sure the foundset on that form is correct and you're on the correct selected record?

Because this:
Code: Select all
forms.frm_form1.foundset.person_name

is pointing directly to the column 'person_name' in the foundset, which is taken direcly from the connected table (I assume you did connect a table to 'frm_form1'?!)
That has absolutely nothing to do with the field/fieldname you have put on your form.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: How to get field value of Solution Model Field

Postby hareendra » Wed Jan 29, 2014 2:51 pm

Sorry for the confusion.
No I did not map my form to a table. I created a form without a table. then using the solution model, I created a data source. I will give the entire code:

var _sql = "SELECT person_name FROM table1;

var _dataset = databaseManager.getDataSetByQuery(globals._active_server, _sql, null, -1);

if(_dataset.getMaxRowIndex() > 0) {
elements.tab1.removeAllTabs();

var _data_source1 = _dataset.createDataSource('data_source1',[JSColumn.TEXT]);

var _form1 = solutionModel.getForm('frm_form1');

var _field1 = _form1.newTextField('person_name', 100, 100, 140, 20);
_field1.name = 'person_name';

Then I need to get the person_name of the selected record of the form.

I tried doing:
application.output(forms.frm_form1.foundset.person_name)

I get a null value.

Regards,
Hareendra
hareendra
 
Posts: 98
Joined: Wed Sep 17, 2008 11:41 am

Re: How to get field value of Solution Model Field

Postby ROCLASI » Wed Jan 29, 2014 4:10 pm

Hi Hareendra,

You are forgetting to put the datasource on the form like so:
Code: Select all
var _data_source1 = _dataset.createDataSource('data_source1',[JSColumn.TEXT]);
var _form1 = solutionModel.getForm('frm_form1');
_form1.dataSource = _data_source1;


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: How to get field value of Solution Model Field

Postby mboegem » Wed Jan 29, 2014 4:12 pm

Yes, Roclasi is right… that are my thoughts as well…

I stand by my previous post: foundset.person_name should return the correct value.
Something else is wrong.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Forms

Who is online

Users browsing this forum: No registered users and 7 guests

cron