Including Custom Properties in a Mashup
The following steps provide a best practice for including properties in a mashup:
1. Add a custom property to the _AP Data Shape as described in Adding Custom Properties to Data Model Entities. For this example, we continue with the custom City property added to the PTC.JobOrder.JobOrder_AP Data Shape.
2. Create a new Data Shape with field definitions from both the main entity Data Shape and the _AP Data Shape.
For this example, create a new Data Shape named MyJobOrder. Add field definitions for ID (from the PTC.JobOrder.JobOrder Data Shape) and City (from the PTC.JobOrder.JobOrder_AP Data Shape).
4. On the new manager, under Services, add a new service to create instances of the Data Shape created in step 2. For both the input and output parameters, use an infotable of the new Data Shape.
For this example, add a new service named AddMyJobOrder, with an infotable of the MyJobOrder Data Shape for both the input and output parameters. In the service editor, enter code similar to the following:
var jobOrderManagerThingName = me.GetJobOrderManager();
var newJobOrders = Things[jobOrderManagerThingName].AddJobOrders({
JobOrders: myJobOrders
});

//Put new job orders in a new info table of MyJobOrder in order to filter the return attribute, this is not required.
var result =DataShapes["MyJobOrder"].CreateValues();
var tableLength = newJobOrders.rows.length;
for (var x=0; x < tableLength; x++) {
var row = newJobOrders.rows[x];
result.AddRow(row);
}
5. Using the new service in a mashup creates new instances of the entity with the custom property present. In this example, using the AddMyJobOrder service in a mashup creates new job orders with the ID property populated in the PTC.JobOrder.JobOrder database table, and the custom City property populated in the PTC.JobOrder.JobOrder_AP database table.
Was this helpful?