Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hi,
I have a Data shape with Friendly Names, I have an infotable where I have renamed the columns as per the Fields of the DataShape which has the Friendly Names and is assigned to the result(a infotable which is created based on the DataShape which has the Friendly Names).
When this is done, friendly names are not getting applied on the Runtime.
Thanks,
Solved! Go to Solution.
Hi,
I found an exciting learning when I was debugging this issue. When we convert the Infotable to JSON, There will be Sub JSON with DataShape, where you can see the below details of the fields in the JSON:
1. Friendly Name
2. Ordinial
3. Name
4. description
... etc
So, we can convert the info table to JSON, update this information like the normal field, and convert it back to the Info table. So that in the result, you will see the proper one as you wanted.
The infotable I am getting doesn't have the Friendly Names. Even if I have renamed the Fields based on the Output Infotable Datashape, it will not show up since the JSON has no Friendly Name.
Thanks.
hi @achirila ,
That's the whole query, can't explain more than that
Thanks
Where do you expect to see the friendly names in runtime would be one question. E.g. as Grid Headers? Or where?
I actually do not know what the feature behind "friendly names" exactly is.
I only found out that it seems to use the friendly name in composer-result view:
DataShape with a property "FieldName" and a friendlyname set:
Service output result shows "Friendlyname" as header:
Mashup only shows "FieldName"
Not sure of the intended use of "FriendlyName"-feature.
Edit: In the docs I only found that this widget makes use of friendlynames in runtime: https://support.ptc.com/help/thingworx/platform/r9/en/?#page/ThingWorx/Help/Mashup_Builder/Widgets/PropertyDisplayWidgetThemable.html (if you search for "friendly name" on the page you find "If the field has a friendly name defined in the Data Shape definition, this name is used.")
Hi @nmutter ,
- I am not pretty sure of the friendly name feature, too. I have been using it for a couple of months now.
- Usually, the Team uses it to show the headers on a custom-made widget on runtime, similar to Grid.
- If you have friendly names set, then when you run the service in the composer also, you will see it as headers of the infotable that confuses in some use cases
Issue is:
When I assign the Infotable of Var to another Infotable(a data shape with Friendly Names) of the same fields, these friendly names are not rendered on the Screen.
I think now I know what you try to do:
let dataShapeAInfotableWithData = // get the data from somewhere
// service return result is set to be of type DataShape B
result = dataShapeAInfotableWithData;
If that is your issue I can explain it: Defining a result datatype is not converting the result of the service into the specified return type. This is just for "developer" interest/documentation basically. The result should be of that type. If the service returns a different type, this type is returned. In your case you still return DataShapeA, not B.
To fix your issue you would have to create a new Infotable of the correct DataShapeB and add all rows of the other infotable. E.g.
let dataShapeAInfotable = undefined; // get data from somewhere
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(AcceptableMissedPings)
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "DataShapeB"
});
dataShapeAInfotable.rows.toArray().forEach(row => {
result.AddRow(row);
});
Hope that helps!
Hi,
I found an exciting learning when I was debugging this issue. When we convert the Infotable to JSON, There will be Sub JSON with DataShape, where you can see the below details of the fields in the JSON:
1. Friendly Name
2. Ordinial
3. Name
4. description
... etc
So, we can convert the info table to JSON, update this information like the normal field, and convert it back to the Info table. So that in the result, you will see the proper one as you wanted.
The infotable I am getting doesn't have the Friendly Names. Even if I have renamed the Fields based on the Output Infotable Datashape, it will not show up since the JSON has no Friendly Name.
Thanks.