# Field without name. Can I get it's dataProvider?

**URL:** https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386
**Category:** Classic Servoy
**Created:** [August 1, 2011, 10:18am UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386 "2011-08-01T10:18:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![maservoy](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@maservoy](https://forum.servoy.com/u/maservoy)
#### Post date: [August 1, 2011, 10:18am UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386/1 "2011-08-01T10:18:49Z")

</div>

Hello,  
I am working on an application which has many forms and on each form many fields without a name.

I am having trouble because I want to find out the dataProvider of the focused field.  
I am using the onElementFocusGained event to find out that an element has been focused.  
My trouble is that I don’t know how to retrieve the element’s dataProvider without a name.

Is this possible? Or am I asking for an impossible?  
Thanks in advance and regards,  
Miguel.-

---

<div class="post-metadata">

### Author: ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)
#### Post date: [August 1, 2011, 12:14pm UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386/2 "2011-08-01T12:14:56Z")

</div>

In the onFocusGained method you get an event as the first argument, you should be able to get the dataprovider like this:

```auto
event.getSource().dataProviderID

```

Having said that, why wouldn’t you give your fields a name?

---

<div class="post-metadata">

### Author: ![maservoy](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@maservoy](https://forum.servoy.com/u/maservoy)
#### Post date: [August 1, 2011, 1:44pm UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386/3 "2011-08-01T13:44:57Z")

</div>

Great, thanks a lot.  
We didn’t use to name fields unless we wanted to use them in our code.

It is obvious that it was an error. From now on, we’ll name every field.

---

<div class="post-metadata">

### Author: ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)
#### Post date: [August 1, 2011, 2:10pm UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386/4 "2011-08-01T14:10:57Z")

</div>

If you want, you can make a method that fills all the names in Servoy 6.

You have to loop through your forms and set the names of the fields that have none, using the solutionModel.  
Then to save it, you have to go to the Command Console and do:```  
servoyDeveloper.save()

```auto

```

---

<div class="post-metadata">

### Author: ![maservoy](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@maservoy](https://forum.servoy.com/u/maservoy)
#### Post date: [August 2, 2011, 7:43am UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386/5 "2011-08-02T07:43:42Z")

</div>

That is more than expected.  
Thanks a lot, Joas. We’ll certainly do it.

By the way, I am testing your code

> event.getSource().dataProviderID

Is this maybe a new feature on Servoy 6?  
It doesn’t seem to work on Servoy 5.2.8

---

<div class="post-metadata">

### Author: ![maservoy](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@maservoy](https://forum.servoy.com/u/maservoy)
#### Post date: [August 2, 2011, 2:08pm UTC](https://forum.servoy.com/t/field-without-name-can-i-get-its-dataprovider/14386/6 "2011-08-02T14:08:52Z")

</div>

I got the right one, Joas:  
Instead of event.getSource().dataProviderID we need to use event.getSource().getDataProviderID()  
Thanks again for the clue.
