cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Selecting a certain data from a table

kbadr
1-Newbie

Selecting a certain data from a table

Hello,

I would like to know how is it possible to select an info or data (cell) from a table?

for example if i would like to select Line = 65 ?

Thanks in advance

8 REPLIES 8
supandey
19-Tanzanite
(To:kbadr)

Karim, you can use the existing code snippet for the Infotable i.e. Create query for an Infotable something like this

ankigupta
5-Regular Member
(To:kbadr)

Hi Karim BADR​,

We can read it like below:

For particular cell: result.rows[1].Line;

For complete row: result.rows[1];

I tried to get the value from one cell like in the example but its not working for me 

its shows me this error 'com.thingworx.dsl.engine.adapters.ThingworxInfoTableAdapter cannot be cast to com.thingworx.types.InfoTable'

kbadr
1-Newbie
(To:kbadr)

Thanks but i get the data from csv file as below :

so how after that i connect the query of calling one line or a certain value with this script? or create other service to do this ?

supandey
19-Tanzanite
(To:kbadr)

Karim, you can use the code snippet from Ankit, see his thread above, in your same service or mine whatever way you are comfortable.

However, you probably would want to query some other Infotables, so you can create a new generic service to avoid writing same set of code again and again - which can take Infotable as input, instead of overloading this existing one.

Then you can simply input your infotable that you are creating above or any other infotable to run your query on it.

Hope this helps.

ankigupta
5-Regular Member
(To:kbadr)

Karim BADR​,

Following are the steps:

First create a datashape of this result. You can do this by just running the service using test button and clicking Create Datashape from result.

Now use the snippet 'create infotable from Datashape' before this script and pass the output of csv to that infotable.

Now you can simply use <Infotable_name>.rows[0].<Field_Name> to refer to a field.

I hope it helps.

Thanks,

Ankit Gupta

kbadr
1-Newbie
(To:kbadr)

Hello,

Thanks alo for your help

as I am still discovering thingworx so i hope not asking much

how can I simply select a certain data or line from a table on the mashup? as i don't know how to use the script above

the infotable name is the name of the service or the name of datashape?

ankigupta
5-Regular Member
(To:kbadr)

Hi Karim BADR​,

Infotable is DataType. So, It cannot be a Service or a datashape.

Generally output variable of a Service is named result. This variable result can be of type Infotable.

To get a field of a row; just open the 'selected row(s)' option of your service and corresponding field be give us the output of the selected row.

Top Tags