Array of objects in freemarker

532 views
Skip to first unread message

com...@vaquerotrading.com

unread,
May 15, 2018, 11:40:25 AM5/15/18
to Fujitsu RunMyProcess Developer Community
I have a composite API with two box, the first box read from zoho reports the contracts available for the vendor but the second read the details for each contract from the firs process box, i have my issue on the second box when try to assign the data to an object, just show the data from the last iteration.

How can I fill my object with the data of all iterations?

Here my freemarker script
<#assign arr=[]>
<#list Det as x>
<#assign contr=x.column[0].P_value>
<#assign class=x.column[1].P_value>
<#assign hw=x.column[2].P_value>
<#assign pr=x.column[3].P_value>
<#assign sl=x.column[4].P_value>
<#assign my_json>
{"Contract":"${contr}","Class":"${class}","HeadWeight":"${hw}","Price":"${pr}","Slide":"${sl}"}
</#assign>
</#list>
${my_json}

Cordially
Edgar Montoya

Contract Detail API Conf.PNG
Contract Detail API.PNG
Contract API.PNG

Pankaj Kumar

unread,
May 16, 2018, 5:47:49 PM5/16/18
to Fujitsu RunMyProcess Developer Community
Hi Edgar,

It is due to in each loop iteration " my_json" is overwrite the value of previous iteration, I change your code and adding  "my_json" to yout "arr" vaiable.

<#assign arr=[]>
        <#list Det as x>
                <#assign contr=x.column[0].P_value>
                <#assign class=x.column[1].P_value>
                <#assign hw=x.column[2].P_value>
                <#assign pr=x.column[3].P_value>
                <#assign sl=x.column[4].P_value>
                <#assign my_json>
                        {"Contract":"${contr}","Class":"${class}","HeadWeight":"${hw}","Price":"${pr}","Slide":"${sl}"}
                </#assign>
<#assign arr = arr + [my_json] />
</#list> 
${ arr }

Kindly let me know if you face any issue on the script.

Thank you,
Pankaj Kumar
Fujitsu RunMyProcess Support

--

“Vaquero Trading is a registered trademark."

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum+unsubscribe@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at https://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/17ff09ec-cee2-46a4-9305-3c7bad26741e%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.

com...@vaquerotrading.com

unread,
May 17, 2018, 2:33:11 PM5/17/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com


Hi Pankaj

Im tried your suggest but just show the values of the last iteration, each iteration have at least 5 results and just show the 5 values of my lat iteration.

Cordially
Edgar Montoya

Pankaj Kumar

unread,
May 17, 2018, 3:12:17 PM5/17/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
Hi Edgar,

Please share the data in "det" variable, it will help me to test the script in my local environment check  value in "arr" variable. You can send data to me privately also on "pku...@runmyprocess.com"

Thank you,
Pankaj Kumar
Fujitsu RunMyProcess Support


Cordially
Edgar Montoya

--

“Vaquero Trading is a registered trademark."

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum+unsubscribe@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at https://groups.google.com/a/runmyprocess.com/group/supportforum/.

com...@vaquerotrading.com

unread,
May 17, 2018, 3:35:28 PM5/17/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
On Tuesday, 15 May 2018 09:40:25 UTC-6, com...@vaquerotrading.com wrote:

Hi Pankaj
I shared with you some screenshots of the data I want to assign in my Det2 var

Det Data First Iteration.PNG
arr Data as Det2.PNG
Contract list.PNG
Data for Det2.PNG
Det Data First Iteration.PNG
Det Data Second iteration.PNG
Det Data Last Iteration.PNG

Pankaj Kumar

unread,
May 17, 2018, 4:35:52 PM5/17/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
Hi Edgar,

Sorry to add this in previous post but I need data in text not in screen-print. Please click on process instance -> select variable "det" -> copy variable value using copy button and save it in a text file.

Please share text file. I can use this text file to validate script.

Thank you,
Pankaj Kumar
Fujitsu RunMyProcess Support

--

“Vaquero Trading is a registered trademark."

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum+unsubscribe@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at https://groups.google.com/a/runmyprocess.com/group/supportforum/.

com...@vaquerotrading.com

unread,
May 17, 2018, 7:12:21 PM5/17/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
On Tuesday, 15 May 2018 09:40:25 UTC-6, com...@vaquerotrading.com wrote:
IN the first iteration I'm searching for contract details where number it's 406, the second iteration where contract number its 606, etc, the last iteration where the contract number it's 742 and it is the value assigned on the last iteration

[{"column":[{"P_value":"742","@name":"Contract"},{"P_value":"2","@name":"Class"},{"P_value":"400-499","@name":"HeadWeight"},{"P_value":"1.76","@name":"Price"},{"P_value":"300/1/10","@name":"Slide"}]},{"column":[{"P_value":"742","@name":"Contract"},{"P_value":"1 1/2","@name":"Class"},{"P_value":"300-399","@name":"HeadWeight"},{"P_value":"1.96","@name":"Price"},{"P_value":"300/1/10","@name":"Slide"}]},{"column":[{"P_value":"742","@name":"Contract"},{"P_value":"1 1/2","@name":"Class"},{"P_value":"500-599","@name":"HeadWeight"},{"P_value":"1.76","@name":"Price"},{"P_value":"300/1/10","@name":"Slide"}]},{"column":[{"P_value":"742","@name":"Contract"},{"P_value":"2","@name":"Class"},{"P_value":"500-599","@name":"HeadWeight"},{"P_value":"1.66","@name":"Price"},{"P_value":"300/1/10","@name":"Slide"}]},{"column":[{"P_value":"742","@name":"Contract"},{"P_value":"1 1/2","@name":"Class"},{"P_value":"400-499","@name":"HeadWeight"},{"P_value":"1.86","@name":"Price"},{"P_value":"300/1/10","@name":"Slide"}]},{"column":[{"P_value":"742","@name":"Contract"},{"P_value":"1 1/2","@name":"Class"},{"P_value":"600-699","@name":"HeadWeight"},{"P_value":"1.71","@name":"Price"},{"P_value":"300/1/10","@name":"Slide"}]}]

Pankaj Kumar

unread,
May 18, 2018, 5:28:09 PM5/18/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
Hi Edgar,

Please find the script as below:-

<#assign arr=[]>
        <#list Det as x>
<#assign my_json = {}>
<#assign my_json = P_json_put(my_json, "Contract", x.column[0].P_value)>
<#assign my_json = P_json_put(my_json, "Class", x.column[1].P_value)>
<#assign my_json = P_json_put(my_json, "HeadWeight", x.column[2].P_value)>
<#assign my_json = P_json_put(my_json, "Price", x.column[3].P_value)>
<#assign my_json = P_json_put(my_json, "Slide", x.column[4].P_value)>
    <#assign arr = arr + [my_json] />
</#list> 
${ arr }

This script is returning below data as per the value you shared for "Det" variable

[{"Price":1.76,"Slide":"300/1/10","HeadWeight":"400-499","Class":2,"Contract":742},{"Price":1.96,"Slide":"300/1/10","HeadWeight":"300-399","Class":"1 1/2","Contract":742},{"Price":1.76,"Slide":"300/1/10","HeadWeight":"500-599","Class":"1 1/2","Contract":742},{"Price":1.66,"Slide":"300/1/10","HeadWeight":"500-599","Class":2,"Contract":742},{"Price":1.86,"Slide":"300/1/10","HeadWeight":"400-499","Class":"1 1/2","Contract":742},{"Price":1.71,"Slide":"300/1/10","HeadWeight":"600-699","Class":"1 1/2","Contract":742}]

Note:- Kindly refer to attached screen-print fro reference

Thank you,
Pankaj Kumar
Fujitsu RunMyProcess Support

--

“Vaquero Trading is a registered trademark."

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum+unsubscribe@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at https://groups.google.com/a/runmyprocess.com/group/supportforum/.
1.PNG

com...@vaquerotrading.com

unread,
May 18, 2018, 7:36:39 PM5/18/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
On Tuesday, 15 May 2018 09:40:25 UTC-6, com...@vaquerotrading.com wrote:

Dear Pankaj

I got the 6 rows on the last iteration, the process box its a multiinstance sequence, the first iteration have 6 result rows, the second iteration have 4 result rows, third iteration 7 result rows, etc.

Cordially
Edgar Montoya

com...@vaquerotrading.com

unread,
May 21, 2018, 12:05:40 PM5/21/18
to Fujitsu RunMyProcess Developer Community, com...@vaquerotrading.com
On Tuesday, 15 May 2018 09:40:25 UTC-6, com...@vaquerotrading.com wrote:

Hi Pankaj!

I only got the rows of my last iterations, how can I take the values of the previous iterations?

Cordially
Edgar Montoya

Pankaj Kumar

unread,
Jul 9, 2018, 9:07:43 AM7/9/18
to Fujitsu RunMyProcess Developer Community, Edgar Montoya
Hi Edgar,

Extremely sorry for delay in response. Since there is change in policy of RunMyProcess Public Support community, We can not access your account without proper contract/agreement.

If you can give us simple steps so that we can reproduce this issue in our account, we can work on it in our account.

Also If you want to take our help please contact  RunMyProcess Sales team to purchase the hours of "professional support", once you have the contract/hours, RunMyProcess team will work on your account to resolve it and charge you for the hours spent.

Thank you,
Pankaj Kumar
Fujitsu RunMyProcess Support


Cordially
Edgar Montoya

--

“Vaquero Trading is a registered trademark."

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum+unsubscribe@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at https://groups.google.com/a/runmyprocess.com/group/supportforum/.
Reply all
Reply to author
Forward
0 new messages