Variable declaration error in JS environment

542 views
Skip to first unread message

yves.d...@gmail.com

unread,
Jan 28, 2015, 2:06:57 PM1/28/15
to suppor...@runmyprocess.com
Hello,

In a JS environnement <@script env="javascript"> , basic variable declaration doesn't work

var a = new Date(); provokes error : Illegal class : org.mozilla.javascript.NativeDate
var b = new Number(); provokes error : Illegal class : org.mozilla.javascript.NativeNumber

but it works if the variable declaration is inside a formula :
var a =new Number(4)/1; is fine as well as var a = new Date().getDay();

So below script is fine
<@script env="javascript">
var day = new Date().getDay();
var number_4 = new Number(4)/1;
setVariable("day",day);
setVariable("number_4",number_4);
</@script>

but not
<@script env="javascript">
// var day = new Date();
var number_4 = new Number(4);
setVariable("day",day);
setVariable("number_4",number_4);
</@script>

Same error message in IE10, Chrome and Firefox.
Why ?

Regards
Yves

thoshino

unread,
Jan 30, 2015, 6:44:03 PM1/30/15
to suppor...@runmyprocess.com, yves.d...@gmail.com
Hi Yves,

You are using this in Process script, correct?

I tried your code and I get this error, at each setVariable().
org.runmyprocess.json.JSONException: Illegal class : org.mozilla.javascript.NativeDate
org.runmyprocess.json.JSONException: Illegal class : org.mozilla.javascript.NativeNumber

Javascript inclusion is executed as server-side Javascript, and inside the script Javascript data types are okay, but once it tries to send as process variable it errors.
This is because process variable is JSON based, and only data type supported are number, string, boolean, array.

Related to this section in Wikipedia
(but please note, data types like null and undefined are also not supported)

And this should happen for all browsers because it is server-side javascript, it is not running in browser.

I hope this makes sense.

Best regards,

Taka

yves.d...@gmail.com

unread,
Feb 3, 2015, 2:06:54 PM2/3/15
to suppor...@runmyprocess.com, yves.d...@gmail.com
Thanks Taka for these explanations and the Wikiepedia link. Indeed I used this script in Process script (input / output variable).
But after reducing the code to only Number variable, I still got the error ?

<@script env="javascript">
var number_4 = new Number(4);
setVariable("number_4",number_4);
</@script>

: Illegal class : org.mozilla.javascript.NativeNumber

Number should be a supported datatype if I read you well ?

Regards
Yves

Takafumi Hoshino

unread,
Feb 3, 2015, 2:21:55 PM2/3/15
to suppor...@runmyprocess.com, Yves de Veyrac
Hi Yves,

I think there is still difference between NativeNumber object and number object.
Please try this script.

<@script env="javascript">
var number_4 = new Number(4);
var a = typeof number_4
var b = typeof 4;
print(a);
print("\n");

print(b);
print("\n");
</@script>

a is type: object
b is type: number

and process variable do not accept object, but will accept number.

Best regards,

Taka


Regards
Yves

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/99bdac74-1ebf-4ff6-8d1e-7f6c7970d007%40runmyprocess.com.



--
---------------------------------------------------
Taka Hoshino
Fujitsu RunMyProcess
Google Account: thos...@runmyprocess.com
<Sent from Gmail web client>

Reply all
Reply to author
Forward
0 new messages