Javascript in process input variable

251 views
Skip to first unread message

sagar....@flowian.com

unread,
Jan 2, 2015, 5:28:52 AM1/2/15
to suppor...@runmyprocess.com
Hi Team,

In my web interface I have taken one array widget. In which one column "Total" is of type Number.

I am trying to set values in this array widget's "Total" column from Javascript which is included in the "Input Variable" tab as shown below

<@script env="javascript">

my_array.total[0]=12;

</@script>

But the error I got is like this ------>

Invalid javascript.: TypeError: Cannot set property "0.0" of undefined to "12" (<
function ...>#129)

"my_array" is the name of array widget.

Regards,
Sagar

Bidisha Das

unread,
Jan 2, 2015, 8:19:38 AM1/2/15
to suppor...@runmyprocess.com
Hi Sagar,
Are you able to get the Column "total" in your process initial parameters? If not,you can check the check box "initialize" in the column "Total" of the array widget and no need to put any default value.This will prevent error in execution in case you leave the particular column(total)  empty and trigger the process.

To set value, you can use the following code: <@script env="javascript">
                                                                   setVariable("my_array.total[0]",12)
                                                                   </@script>

Thanks & Regards
Bidisha

sagar....@flowian.com

unread,
Jan 3, 2015, 1:45:33 AM1/3/15
to suppor...@runmyprocess.com
Hi Bidisha,

When I use the below code for setting the array value
<@script env="javascript"> setVariable("my_array.total[0]",12); </@script>

It will add new node to the "my_array". I want that the value should add into my_array.total[]. Rather than it creates "my_array.total[0]" new node.

Regards,
Sagar

Muralikrishna Kummaragunta

unread,
Jan 3, 2015, 3:28:26 AM1/3/15
to suppor...@runmyprocess.com
Hi Sagar,

In above script, for sure we are not adding any new row(node) for the array widget, it only sets the value of existing array column based on row index of array.

Please send complete code and process configuration and related run-time screenshots to analyze and suggest you further.

Regards,
Murali



--
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/bc3e42b5-8555-4b72-bad8-fac615f31784%40runmyprocess.com.



--
Regards,
Murali

Shobhit Tripathi

unread,
Jan 3, 2015, 6:50:16 PM1/3/15
to suppor...@runmyprocess.com
Hi Sagar,

As per your first post you are getting error while assigning the value in array. This is because of you are using array index to assign value but internally it will not found any array column.

Have you initialized the array column "Total" ?

To do so please follow below steps:

1. Initialize the array column. Please find the screenshot for more information.
2. Use your code in process activity (input variable).

Let us know if you are still getting the same problem.

Thanks & Regards,
Shobhit
Fujitsu - RunMyProcess




--
Thanks & Regards,
Shobhit
Fujitsu- RunMyProcess
Array column initialize.jpg

Bidisha Das

unread,
Jan 4, 2015, 4:34:45 AM1/4/15
to suppor...@runmyprocess.com
Hi Sagar,
For that, you need to make a small change in the freemarker code I provided you above: 

<@script env="javascript">
setVariable("my_array.total[0]",["12"]) [ pass the value 12 in array format]

Bidisha Das

unread,
Jan 4, 2015, 5:05:19 AM1/4/15
to suppor...@runmyprocess.com
Hi Sagar,
Just missed one thing. No need to use index[0]. Please follow the code below:

<@script env="javascript">
setVariable("my_array.total",["12"]) [ pass the value 12 in array format]

sagar....@flowian.com

unread,
Jan 5, 2015, 12:38:23 AM1/5/15
to suppor...@runmyprocess.com
Hi Bidisha and Shobhit,

Thanks for your support.

I have implemented shobhit's solution and its working fine.

Regards,
Sagar
Reply all
Reply to author
Forward
0 new messages