# dataproviderID setting to null

**URL:** <https://forum.servoy.com/t/dataproviderid-setting-to-null/16788>\
**Category:** Classic Servoy\
**Created:** [November 27, 2012, 3:58pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788 "2012-11-27T15:58:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 27, 2012, 3:58pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/1 "2012-11-27T15:58:00Z")

</div>

HI,

I have some method where I scan all the elements of a form and get the dataproviderID of an element.

```auto
var vProviderID = forms[vForm].elements[vElem].getDataProviderID()

```

Now for example this code returns vProviderID as a string: “scopes.globals.filter\_monthfilter”  
How do I set this global now to null?

---

<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:** [November 28, 2012, 1:02pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/2 "2012-11-28T13:02:39Z")

</div>

Try something like:

```auto
	if (/^scopes\./.test(vProviderID)) {
		var split = vProviderID.split(".");
		scopes[split[1]][split[2]] = null;
	}

```

You probably need to do some more checks, but you get the idea.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 28, 2012, 1:14pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/3 "2012-11-28T13:14:55Z")

</div>

yes I did something like that already, but we still have code run in Servoy 6 and Servoy 6.1  
In Servoy 6 there is ‘scopes.’ in front, so I wanted to make this just work on both…

But you say, that is not possible?

---

<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:** [November 28, 2012, 2:17pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/4 "2012-11-28T14:17:20Z")

</div>

So you want the same code to work in 6.0 and 6.1? That doesn’t look like a good idea to me, but it is possible if you do something like:

```auto
   var split = vProviderID.split(".");
   if (/^globals\./test(vProviderID)) {
      globals[split[1]] = null;
   } else if (/^scopes\./.test(vProviderID)) {
      scopes[split[1]][split[2]] = null;
   }

```

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 28, 2012, 4:19pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/5 "2012-11-28T16:19:14Z")

</div>

No, but i thought there was maybe another way to set a (global) dataprovider independant of the name.

---

<div class="post-metadata">

**Author:** ![jbrancoIF](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@jbrancoIF](https://forum.servoy.com/u/jbrancoIF)\
**Post date:** [November 28, 2012, 4:33pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/6 "2012-11-28T16:33:45Z")

</div>

this should work:

```auto
eval(vProviderID + '=null;')

```

or if you have a form

```auto
vForm.controller.setDataProviderValue(vProviderID, null)

```

---

<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:** [November 28, 2012, 4:45pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/7 "2012-11-28T16:45:33Z")

</div>

> Harjo:  
> No, but i thought there was maybe another way to set a (global) dataprovider independant of the name.

Hmmm, I’m don’t think I understand correctly what you are trying to do.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 28, 2012, 7:59pm UTC](https://forum.servoy.com/t/dataproviderid-setting-to-null/16788/8 "2012-11-28T19:59:32Z")

</div>

> jbrancoIF:  
> this should work:
> 
> ```auto
> eval(vProviderID + '=null;')
> 
> ```
> 
> or if you have a form
> 
> ```auto
> vForm.controller.setDataProviderValue(vProviderID, null)
> 
> ```

YES jBrancoIF, you are the man!

```auto
vForm.controller.setDataProviderValue(vProviderID, null)

```

works perfectly. and despite of the name is ‘scopes.globals.myglobal’ (6.1.x) or ‘globals.myglobal’ (6.0.x)

Thanks!
