# Is x = forms.formname\[relname,fieldname\] supported syntax?

**URL:** <https://forum.servoy.com/t/is-x-forms-formname-relname-fieldname-supported-syntax/7396>\
**Category:** Classic Servoy\
**Created:** [April 25, 2007, 10:01am UTC](https://forum.servoy.com/t/is-x-forms-formname-relname-fieldname-supported-syntax/7396 "2007-04-25T10:01:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 25, 2007, 10:01am UTC](https://forum.servoy.com/t/is-x-forms-formname-relname-fieldname-supported-syntax/7396/1 "2007-04-25T10:01:19Z")

</div>

Hi,

I’m trying to write a flexible substitution system for bulk mailing,

I have a form, let’s call it ‘mailinglist’. I use controller.setSelectedIndex() in a loop to move down the list.

to get the value relating to a specific record, I use

```auto
var relationshipname = arguments[0];
var fieldname = arguments[1];
var v = forms.mailinglist[relationshipname,fieldname];

```

assuming this will pick the value for the current record.

It doesn’t!!!  
It always picks up the value of the first record.

Is this syntax supported, so this is a Servoy bug…  
or  
am I streching javascript too far and need to rewrite?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 25, 2007, 10:09am UTC](https://forum.servoy.com/t/is-x-forms-formname-relname-fieldname-supported-syntax/7396/2 "2007-04-25T10:09:05Z")

</div>

Instead of setting the selected index, you should use getRecord. So change your code to something like

```auto
for (var i = 1; i <= foundset.getSize(); i++) {
   var vRecord = foundset.getRecord(i);
   // now call your method and pass the record
   myMethod(vRecord, 'relationshipName', 'fieldName');
}

```

in “myMethod” you do

```auto
var vRecord = arguments[0];
var relationshipname = arguments[1];
var fieldname = arguments[2];
var v = vRecord[relationshipname][fieldname];

```

Using getRecord() is a lot faster than setting the selectedIndex and is more robust in general.

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 25, 2007, 10:25am UTC](https://forum.servoy.com/t/is-x-forms-formname-relname-fieldname-supported-syntax/7396/3 "2007-04-25T10:25:24Z")

</div>

just tried:

```auto
var x = controller.getDataProviderValue(relationshipname + '.' + fieldname);

```

Same error I get the first record in the list, although I can see

```auto
controller.getSelectedIndex()

```

increasing…

Servoy 3.1.3\_01  
Mac OS X  
Java 1.5

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 25, 2007, 10:33am UTC](https://forum.servoy.com/t/is-x-forms-formname-relname-fieldname-supported-syntax/7396/4 "2007-04-25T10:33:18Z")

</div>

Thank you Patrick, your technique works fine! And is of course faster 😉
