data type errors

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.

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:

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.

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

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

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

application.output(typeof(forms.testAnalysis.sevenid))

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

Returns as “number”.

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

Regards.

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.

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.

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.

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.

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