Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
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
Solved! Go to Solution.
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
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
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.