# data type errors

**URL:** <https://forum.servoy.com/t/data-type-errors/2225>\
**Category:** Classic Servoy\
**Created:** [July 12, 2004, 8:24pm UTC](https://forum.servoy.com/t/data-type-errors/2225 "2004-07-12T20:24:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [July 12, 2004, 8:24pm UTC](https://forum.servoy.com/t/data-type-errors/2225/1 "2004-07-12T20:24:49Z")

</div>

I have a set of global fields plus regular table fields both of integer type. Nevertheless, when I attempt to reset the globals I’m getting a field type error from JavaScript.

```auto
globals.gseven_id = forms.testAnalysis.sevenid;
globals.guser_id = forms.testAnalysis.userid;

```

At the beginning of the exercise, the two globals have values of “0”, and the test table fields have numerical values 1 and 22. No decimals or any other data entries.

Error message is:

```auto
Setting global with name 'gseven_id' / type 'INTEGER' with value of wrong type org.mozilla.javascript.Undefined@65b1bd

```

Appreciate pointers to what I’m missing. Thanks.

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [July 12, 2004, 9:53pm UTC](https://forum.servoy.com/t/data-type-errors/2225/2 "2004-07-12T21:53:17Z")

</div>

Can you change your code into this, and run with debugger?  
(this will check the column type you’re receiving)

```auto
application.output(typeof(forms.testAnalysis.sevenid))
//globals.gseven_id = forms.testAnalysis.sevenid; 
application.output(typeof(forms.testAnalysis.userid))
//globals.guser_id = forms.testAnalysis.userid;

```

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [July 13, 2004, 12:39am UTC](https://forum.servoy.com/t/data-type-errors/2225/3 "2004-07-13T00:39:42Z")

</div>

> maarten:  
> Can you change your code into this, and run with debugger?  
> (this will check the column type you’re receiving)
> 
> ```auto
> application.output(typeof(forms.testAnalysis.sevenid))
> 
> ```

//globals.gseven\_id = forms.testAnalysis.sevenid;  
application.output(typeof(forms.testAnalysis.userid))  
//globals.guser\_id = forms.testAnalysis.userid;

> ```auto
> 
> ```

Returns as “number”.

I’ve been setting ID fields as Integer instead of Number. Not good practice?

Regards.

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [July 13, 2004, 7:13am UTC](https://forum.servoy.com/t/data-type-errors/2225/4 "2004-07-13T07:13:11Z")

</div>

No pk’s as integer is OK.

Please check if the type of your global corresponds with the type of the field you’re trying to set it with.

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [July 13, 2004, 12:35pm UTC](https://forum.servoy.com/t/data-type-errors/2225/5 "2004-07-13T12:35:43Z")

</div>

> maarten:  
> No pk’s as integer is OK.
> 
> Please check if the type of your global corresponds with the type of the field you’re trying to set it with.

The global is quite clearly an integer type as well.

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [July 13, 2004, 12:48pm UTC](https://forum.servoy.com/t/data-type-errors/2225/6 "2004-07-13T12:48:01Z")

</div>

Did you also check that “forms.testAnalysis.sevenid” actually has a value when your script is arriving at line:  
globals.gseven\_id = forms.testAnalysis.sevenid;

Set breakpoint at beginning of this line, activate debugger, when arriving at breakpoint, copy paste “forms.testAnalysis.sevenid” into the evaluate panel of the debugger. Hit enter to evaluate.

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [July 13, 2004, 1:44pm UTC](https://forum.servoy.com/t/data-type-errors/2225/7 "2004-07-13T13:44:44Z")

</div>

Now that’s really startling. No change in code, but now it works.

I had commented out the two critical lines of the method to test alternatives, and now have restored the original coding that generated the type error. I’ve gone to the globals to double check type, didn’t change anything but I 'm more likely to have clicked OK rather than Cancel on exit. Only actions I can think of.

This also happened early on. Had a type error, then spontaneously in the midst of trying to figure out the problem it went away, then returned again. Couldn’t at the time figure out what I had done to cause the fix or what I did to remove the fix.

Puzzling. Working now and won’t play with it further.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [July 23, 2004, 12:00pm UTC](https://forum.servoy.com/t/data-type-errors/2225/8 "2004-07-23T12:00:51Z")

</div>

what happend was that forms.testAnalysis.sevenid was not there somehow.
