Page 1 of 1

How to get record value in form variables

PostPosted: Mon Oct 22, 2012 5:17 pm
by mskv1309
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

Re: How to get record value in form variables

PostPosted: Mon Oct 22, 2012 5:27 pm
by mboegem
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

Re: How to get record value in form variables

PostPosted: Mon Oct 22, 2012 5:50 pm
by mskv1309
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"