How to get record value in form variables

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How to get record value in form variables

Postby mskv1309 » Mon Oct 22, 2012 5:17 pm

I am working with foundset which is loaded dynamically and bound column programmatically that is provided data provider to elements in form programmatically. Loaded all the records. Below is snippet

Code: Select all
var sql="<sql statement>"
   
   var ds=databaseManager.getDataSetByQuery('servername',sql,null,100)   
   var datsource=ds.createDataSource('data')
   var frm = solutionModel.getForm('myForm');
   frm.dataSource=datsource
   
   forms['formname'].controller.recreateUI()
   var elem = frm.getField(forms.formname.elements.colMN.getName());
   elem.dataProviderID = 'COLNM';
   
   var fs=databaseManager.getFoundSet(datsource)
   fs.loadAllRecords()
   forms.formname.foundset.loadRecords(fs)

                  var index=forms.formname.foundset.getSelectedIndex()
   var record=forms.formname.foundset.getRecord(index)
   application.output('RECORD :'+record)
               
                 var varname=record.colname  //store individual values in variables
                    


Here what I want to do.
1. code: record=forms.formname.foundset.getRecord(index). It returns the selected record/row.
2. I want to get individual values in my variable Can I get individual values like-
var varname=record.colname


How to get individual values in variables for a particular record/row. Any suggestion
mskv1309
 
Posts: 41
Joined: Thu Apr 26, 2012 10:05 pm

Re: How to get record value in form variables

Postby mboegem » Mon Oct 22, 2012 5:27 pm

Hi,

if you have the colname in a variable (ie. vColName)
you can get the value like: var varname = record[vColName];

if you have typed the colname literally, var varname = record.colname should work.

Hope this helps
Last edited by mboegem on Mon Oct 22, 2012 5:53 pm, edited 1 time in total.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1382
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: How to get record value in form variables

Postby mskv1309 » Mon Oct 22, 2012 5:50 pm

Thanks Marc,

It worked. As per your code I am able to get value in variable. Given typo still giving me warning
"The property colnm1 is undefined for the type JSRecord"
mskv1309
 
Posts: 41
Joined: Thu Apr 26, 2012 10:05 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 1 guest

cron