Skip to main content
11-Garnet
June 8, 2022
Solved

How to pass nth row of a infotable as argument.

  • June 8, 2022
  • 1 reply
  • 1578 views

i want to loop through each row of infotable and pass the whole row as an argument. is it possible in thing worx.

While writing infotable.rows[0] its  showing error as : (Error executing service. Message ::Unable To Convert From com.thingworx.types.collections.ValueCollection to INFOTABLE)

Best answer by ashaban

Hi @SM_10230689 ,

I can think of two easy ways:

1. You can create a temporary info table with a single row (the row you would like to pass) and The called service will define an info table input parameter and access the first row.

2. Since the row is a JSON object, create a JSON object type parameter on the receiving service and pass the row.

 

Example attached: (Note: I'm not sure what is your ThingWorx Composer version so the syntax might vary)

Thing rowParamter

two services:

1. getInfoTableOrJSON with two inputs (INFOTABLE and JSON) that will print the value of the name

2. test get an info table as input and send each row as an info table and row to getInfoTableOrJSON.

To test:

execute the test service and provide a row (use the Add+)

See the script log prints (it is an error just for visibility)

 

ashaban_0-1654677825025.png

 

ashaban_1-1654677841532.png

 

ashaban_2-1654677848734.png

 

 

ashaban_4-1654677856317.png

 

I hope it helps,

Avihu.

1 reply

ashaban12-AmethystAnswer
12-Amethyst
June 8, 2022

Hi @SM_10230689 ,

I can think of two easy ways:

1. You can create a temporary info table with a single row (the row you would like to pass) and The called service will define an info table input parameter and access the first row.

2. Since the row is a JSON object, create a JSON object type parameter on the receiving service and pass the row.

 

Example attached: (Note: I'm not sure what is your ThingWorx Composer version so the syntax might vary)

Thing rowParamter

two services:

1. getInfoTableOrJSON with two inputs (INFOTABLE and JSON) that will print the value of the name

2. test get an info table as input and send each row as an info table and row to getInfoTableOrJSON.

To test:

execute the test service and provide a row (use the Add+)

See the script log prints (it is an error just for visibility)

 

ashaban_0-1654677825025.png

 

ashaban_1-1654677841532.png

 

ashaban_2-1654677848734.png

 

 

ashaban_4-1654677856317.png

 

I hope it helps,

Avihu.

11-Garnet
June 14, 2022

Hi ashaban,

 

Thanks, the first approach worked, (create a temporary info table with a single row (the row you would like to pass) and The called service will define an info table input parameter and access the first row).

 

Thanks.