Enumerating form elements

Hi,

Im currently working on a function, in which i need the ability to loop through fields contained within tabs on a tab panel and obtain their names or index.
We are using this information to construct and parse a sql string from user data entry.
So we need to know the following

a. if any data is present, what is it and also the field name
and
b. if data is present, what data type is it

I know the names could be hard coded but we need to future proof this as much as possible.

If anyone could offer some help or example code on this it would be much appreciated.

Regards

McCourt Cordingley

As a follow on looking at enumerating form elements - I’ve used this bit of code to list all the elements on a form:

var elementarray = elements.allnames
for(var n = 0; n <= elementarray.length; n++)
application.output(elements[n]);

However - I’m a bit confused by the result - here are some of the rows on a test form:

DataCheckBox[fc_year_by_hand_yn:fc_year_by_hand_yn:1]
DataField[fc_year_by_hand:fc_year_by_hand:9]
DataField[fc_per_complete:fc_per_complete:1.0]
DataCalendar[fc_date_last_test_yearend:null:1989-12-31]
DataCheckBox[fc_surface_preparation_required:fc_surface_preparation_required:0]

After the DataType info the first item appears to be the ‘name’ property for the element. The last is the data in the element on the live form.

Q. Why in some of the rows are there two references the same (i.e. DataCheckBox[fc_surface_preparation_required:fc_surface_preparation_required:0]), yet in some others there is only one reference? Thought at first this was the ‘name’ and the ‘dataprovider’ properties respectively, but others have no second reference? They have a ‘Null’ as in row 4 above yet all have both names and data providers?

Q. Why does this code skip elements where the ‘name’ property is empty? Surely it should still populate the DP name of the element? I note (obviously) that I’m using the ‘.allnames’ method but my expectation would be that the element would be shown as existing with a null name - or is that just dumb?

Q. Is there a method that can list all elements that ‘don’t’ have a ‘name’ property populated?

Feedback would be very useful.

Zuke:
if any data is present, what is it and also the field name

use ‘alldataproviders’ from the formobject and iterate over them.
you can check if any value is there with: forms[$form].alldataproviders **
> Zuke:
> b. if data is present, what data type is it
to retrieve the type you could do something like this:
* _databaseManager.getTable(forms[$form].foundset).getColumn(forms[$form].alldataproviders*).getTypeAsString()*_ _*_
So this is a different approach: instead of iterating the elements you have to iterate the dataproviders.
I think this is the easiest way to get to your goal.
Hope this helps