Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
This simple example creates an infotable of hierarchical data from an existing datashape that can be used in a tree or D3 Tree widget. Attachments are provides that give a PDF document as well as the ThingWorx entities for the example. If you were just interested in the service code, it is listed below:
var params = {
infoTableName : "InfoTable",
dataShapeName : "TreeDataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(TreeDataShape)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var NewRow = {};
NewRow.Parent = "No Parent";
NewRow.Child = "Enterprise";
NewRow.ChildDescription = "Enterprise";
result.AddRow(NewRow);
NewRow.Parent = "Enterprise";
NewRow.Child = "Site1";
NewRow.ChildDescription = "Wilmington Plant";
result.AddRow(NewRow);
NewRow.Parent = "Site1";
NewRow.Child = "Site1.Line1";
NewRow.ChildDescription = "Blow Molding";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line1";
NewRow.Child = "Site1.Line1.Asset1";
NewRow.ChildDescription = "Preform Staging";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line1";
NewRow.Child = "Site1.Line1.Asset2";
NewRow.ChildDescription = "Blow Molder";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line1";
NewRow.Child = "Site1.Line1.Asset3";
NewRow.ChildDescription = "Bottle Unscrambler";
result.AddRow(NewRow);
NewRow.Parent = "Site1";
NewRow.Child = "Site1.Line2";
NewRow.ChildDescription = "Filling";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line2";
NewRow.Child = "Site1.Line2.Asset1";
NewRow.ChildDescription = "Rinser";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line2";
NewRow.Child = "Site1.Line2.Asset2";
NewRow.ChildDescription = "Filler";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line2";
NewRow.Child = "Site1.Line2.Asset3";
NewRow.ChildDescription = "Capper";
result.AddRow(NewRow);
NewRow.Parent = "Site1";
NewRow.Child = "Site1.Line3";
NewRow.ChildDescription = "Packaging";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line3";
NewRow.Child = "Site1.Line3.Asset1";
NewRow.ChildDescription = "Printer Labeler";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line3";
NewRow.Child = "Site1.Line3.Asset2";
NewRow.ChildDescription = "Packer";
result.AddRow(NewRow);
NewRow.Parent = "Site1.Line3";
NewRow.Child = "Site1.Line3.Asset3";
NewRow.ChildDescription = "Palletizing";
result.AddRow(NewRow);
NewRow.Parent = "Enterprise";
NewRow.Child = "Site2";
NewRow.ChildDescription = "Mobile Plant";
result.AddRow(NewRow);
NewRow.Parent = "Site2";
NewRow.Child = "Site2.Line1";
NewRow.ChildDescription = "Blow Molding";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line1";
NewRow.Child = "Site2.Line1.Asset1";
NewRow.ChildDescription = "Preform Staging";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line1";
NewRow.Child = "Site2.Line1.Asset2";
NewRow.ChildDescription = "Blow Molder";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line1";
NewRow.Child = "Site2.Line1.Asset3";
NewRow.ChildDescription = "Bottle Unscrambler";
result.AddRow(NewRow);
NewRow.Parent = "Site2";
NewRow.Child = "Site2.Line2";
NewRow.ChildDescription = "Filling";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line2";
NewRow.Child = "Site2.Line2.Asset1";
NewRow.ChildDescription = "Rinser";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line2";
NewRow.Child = "Site2.Line2.Asset2";
NewRow.ChildDescription = "Filler";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line2";
NewRow.Child = "Site2.Line2.Asset3";
NewRow.ChildDescription = "Capper";
result.AddRow(NewRow);
NewRow.Parent = "Site2";
NewRow.Child = "Site2.Line3";
NewRow.ChildDescription = "Packaging";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line3";
NewRow.Child = "Site2.Line3.Asset1";
NewRow.ChildDescription = "Printer Labeler";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line3";
NewRow.Child = "Site2.Line3.Asset2";
NewRow.ChildDescription = "Packer";
result.AddRow(NewRow);
NewRow.Parent = "Site2.Line3";
NewRow.Child = "Site2.Line3.Asset3";
NewRow.ChildDescription = "Palletizing";
result.AddRow(NewRow);