AnsweredAssumed Answered

Printing JSON Array into a Field

Question asked by luna248 on Oct 10, 2018
Latest reply on Oct 10, 2018 by luna248

I have a whole set of records that I am converting into JSON one-by-one and inserting it into a JSON Array. However, I'm having trouble printing the entire array into a field. Here's the script I'm using to do this:

 

Go to Record/Request/Page[First]

 

Set Variable [$i; Value:0]

Loop

     Set Variable [ $$json; Value: JSONSetElement ("{}" ; ["Company_Name"; FindCompany::Company Name; 1 ] ;      ["Company Type";FindCompany::Company Type; 1 ] ) ]

     Set Variable [ $$json_array; Value: JSONSetElement ( $$array ; $i ; $$json ; JSONRaw ) ]

     Go to Record/Request/Page [ Next; Exit after last: On ]

     Set Variable [ $i; Value: $i+1 ]

End Loop

 

Set Variable [ $j ; Value: 0 ]

Loop

     Set Field[ FindCompany::JSON_text; JSONGetElement ( $$json_array ; ".[" & $j & "].Company_Name" ) ]

     Set Variable [ $j; Value: $j+1 ]

     #There are 500 elements

     Exit Loop if [ $j = 499 ]

End Loop

 

Commit Records/Requests [ With dialog: Off ]

Exit Script [ Text Result: $null ]

 

I think the problem is with the second loop and how I'm trying to print the array into the field. If anyone has any ideas on how I can change that I would appreciate it.

 

Thanks!

Outcomes