dataproviderID setting to null

HI,

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

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?

Try something like:

	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.

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?

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:

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

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

this should work:

eval(vProviderID + '=null;')

or if you have a form

vForm.controller.setDataProviderValue(vProviderID, null)

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.

jbrancoIF:
this should work:

eval(vProviderID + '=null;')

or if you have a form

vForm.controller.setDataProviderValue(vProviderID, null)

YES jBrancoIF, you are the man!

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!