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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Printing multiple rows from single infotable column

Pratik_Aswale
11-Garnet

Printing multiple rows from single infotable column

Hello All,

I have a service which takes a input in string (it is basically a parent equipment name) in the output I am getting an infotable I want to print all assets under that parent. I am to do that but only first equipment is getting printed.

 

PFA and also check data type I might be missing something 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Pratik_Aswale 

 

Based on Screenshot 27 you have what you are asking for, just with additional information.  Depending on what you mean by "print" you can display this in a grid and hide/exclude the extra columns.  Put this in a dropdown and use ThingName as display.

 

If you want the resulting infotable to only include ThingName then you will have to transform the info table into another table by creating a new info table ( I would recommend using OOTB DataShape, EntityList).  Look at the code snipits for info table on how to create, loop, and add entries.

 

Thanks,

 

Travis

View solution in original post

5 REPLIES 5

Hi @Pratik_Aswale 

 

If you want ThingName as a String 

 

let thingNameArray = [];
result1.rows.toArray().forEach( row => {
   thingNameArray.push(row.ThingName);
});

// Convert array to string
let result = thingNameArray.join(",") // Seperate each thingname by comma

 

/VR

Hello,

 

Thanks for the help but I need result in infotable 

Hi @Pratik_Aswale 

 

Based on Screenshot 27 you have what you are asking for, just with additional information.  Depending on what you mean by "print" you can display this in a grid and hide/exclude the extra columns.  Put this in a dropdown and use ThingName as display.

 

If you want the resulting infotable to only include ThingName then you will have to transform the info table into another table by creating a new info table ( I would recommend using OOTB DataShape, EntityList).  Look at the code snipits for info table on how to create, loop, and add entries.

 

Thanks,

 

Travis

Not sure what you mean by "print", but you can:

a) use result1 and drop all columns except ThingName ( I think the service is called RemoveField) and use that as result

 e.g. result=Object.keys(result1.dataShape.fields).forEach(key=>key!="ThingName" && result1.RemoveField(key));

b) Create a new Infotable and add all Thingnames from result1. In that case the return value must be of type INFOTABLE, not STRING.

 

On how to create a populate an infotable I suggest you make yourself familiar with the "Getting to know infotables" PDF which is a valuable resource. https://community.ptc.com/t5/IoT-Tips/Getting-to-Know-InfoTables-pdf/ta-p/818843

 

For your usecase, it could work roughly like this:

 

result = Resources["InfoTableFunctions"].CreateInfoTable();
result.AddField({name: 'ThingName', baseType: 'STRING'});

result1.rows.toArray().forEach(row=>result.AddRow({ThingName:row.ThingName}));

 

 

 

 

Hello @Pratik_Aswale

 

It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Community Moderation Team.

Top Tags