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, and execute the AddColumn service, as described in the previous section. For this example, we continue with the custom Location property added to the PTC.SCA.SCO.JobOrder_AP Data Shape in the previous section.
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.SCA.SCO.JobOrder Data Shape) and Location (from the PTC.SCA.SCO.JobOrder_AP Data Shape).
3. Navigate to the PTC.SCA.SCO.ProductionOrderUtils Thing.
4. 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 CreateMyJobOrder, 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 productionManagerThingName = Things["PTC.Factory.LaunchPointConfigurationThing"].GetProductionOrderManagerThingName();
var newJobOrders = Things[productionManagerThingName].CreateJobOrders({
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 params = {
infoTableName : "InfoTable",
dataShapeName : "MyJobOrder"
};

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
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 CreateMyJobOrder service in a mashup creates new job orders with the ID property populated in the PTC.SCA.SCO.JobOrder database table, and the custom Location property populated in the PTC.SCA.SCO.JobOrder_AP database table.
Was this helpful?