Configuring the Automatic Creation of ServiceMax Events
The following sections provide instructions on how to configure the automatic creation of events in ServiceMax, based on ThingWorx alerts and subscriptions.
Create Alert
1. In ThingWorx Composer, find your asset, for example Asset_PTC.SCA.SCO.Demo.Sim.Pump1.
2. Under
Properties and Alerts, locate the property to which you want to add an alert, for example,
Temperature, and click
in the
Alerts column.
3. Enter the necessary information for the alert, for example:
Information | Value |
---|
Enabled | (checkbox selected) |
Name | HighTemperature |
Description | High temperature detected during operation |
Property | Temperature |
Alert Type | In Range |
Minimum | 300 |
Include Minimum? | (checkbox selected) |
Maximum | 400 |
Include Maximum? | (checkbox cleared) |
Priority | 3 |
4. Click
.
5. Click Save.
Create Subscription
1. In ThingWorx Composer, find your asset, for example Asset_PTC.SCA.SCO.Demo.Sim.Pump1.
2. Under Subscriptions, click Add.
3. Complete the subscription information:
◦ Under Subscription Info:
▪ Source—Me
▪ Enabled—(checkbox selected)
◦ Under Inputs:
▪ Event—Alert
▪ Property—Temperature
4. Add your script which calls the appropriate service of PTC.SCA.SCO.AssetService.Connector.ServiceMax. See the example scripts following this procedure for more information.
5. Click Done.
6. Click Save.
Example Scripts
| The following code examples have been reformatted for presentation purposes, and therefore contain hidden editing characters such as tabs, end-of-line characters, and extraneous spaces. If you copy and paste these examples, check for these characters and remove them before attempting to use the code in your application. |
Create ServiceRequest script:
var otherParams = {
infoTableName: "othersInfoTable", /* STRING */
dataShapeName: "PTC.SCA.SCO.AssetService.Connector.ServiceMaxApiPayloadDataShape.OthersDataShape" /* DATASHAPENAME */
};
// result: INFOTABLE
var othersInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(otherParams);
var othersRow = {
'FieldName': 'AssetSerialNumber',
'FieldValue': 'MySerialNumber'
};
othersInfoTable.AddRow(othersRow);
var params = {
infoTableName: "InfoTable", /* STRING */
dataShapeName: "PTC.SCA.SCO.AssetService.Connector.ServiceMaxApiPayloadDataShape" /* DATASHAPENAME */
};
// result: INFOTABLE
var payloadInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var payloadInfoTableRow = {
'EventDataName': eventData.name,
'EventDataPriority': eventData.priority,
'EventDataMessage': eventData.message,
'EventDataDescription': eventData.description,
'EventDataAlertType': eventData.alertType,
'EventDataSourceProperty': sourceProperty,
'AssetThingName': source,
'EventDataEventTime': '2018-12-00 12:00:00',
'AssetSerialNumber' : ‘MySerialNumber’,
'AssetModelNumber': ‘MyModelNumber’,
'Others': othersInfoTable,
};
payloadInfoTable.AddRow(payloadInfoTableRow);
// create service request
var result = Things["PTC.SCA.SCO.AssetService.Connector.ServiceMaxConnector"].CreateServiceRequest ({eventInfo: payloadInfoTable,alternatePayload:null});
Create Case script:
var otherParams = {
infoTableName: "othersInfoTable", /* STRING */
dataShapeName: "PTC.SCA.SCO.AssetService.Connector.ServiceMaxApiPayloadDataShape.OthersDataShape" /* DATASHAPENAME */
};
// result: INFOTABLE
var othersInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(otherParams);
var othersRow = {
'FieldName': 'AssetSerialNumber',
'FieldValue': 'MySerialNumber'
};
othersInfoTable.AddRow(othersRow);
var params = {
infoTableName: "InfoTable", /* STRING */
dataShapeName: "PTC.SCA.SCO.AssetService.Connector.ServiceMaxApiPayloadDataShape" /* DATASHAPENAME */
};
// result: INFOTABLE
var payloadInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var payloadInfoTableRow = {
'EventDataName': eventData.name,
'EventDataPriority': eventData.priority,
'EventDataMessage': eventData.message,
'EventDataDescription': eventData.description,
'EventDataAlertType': eventData.alertType,
'EventDataSourceProperty': sourceProperty,
'AssetThingName': source,
'EventDataEventTime': '2018-12-00 12:00:00',
'AssetSerialNumber' : ‘MySerialNumber’,
'AssetModelNumber': ‘MyModelNumber’,
'Others': othersInfoTable,
};
payloadInfoTable.AddRow(payloadInfoTableRow);
// create case
var result = Things["PTC.SCA.SCO.AssetService.Connector.ServiceMaxConnector"].CreateCase({eventInfo: payloadInfoTable,alternatePayload:null});
Create WorkOrder script:
var otherParams = {
infoTableName: "othersInfoTable", /* STRING */
dataShapeName: "PTC.SCA.SCO.AssetService.Connector.ServiceMaxApiPayloadDataShape.OthersDataShape" /* DATASHAPENAME */
};
// result: INFOTABLE
var othersInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(otherParams);
var othersRow = {
'FieldName': 'AssetSerialNumber',
'FieldValue': 'MySerialNumber'
};
othersInfoTable.AddRow(othersRow);
var params = {
infoTableName: "InfoTable", /* STRING */
dataShapeName: "PTC.SCA.SCO.AssetService.Connector.ServiceMaxApiPayloadDataShape" /* DATASHAPENAME */
};
// result: INFOTABLE
var payloadInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var payloadInfoTableRow = {
'EventDataName': eventData.name,
'EventDataPriority': eventData.priority,
'EventDataMessage': eventData.message,
'EventDataDescription': eventData.description,
'EventDataAlertType': eventData.alertType,
'EventDataSourceProperty': sourceProperty,
'AssetThingName': source,
'EventDataEventTime': '2018-12-00 12:00:00',
'AssetSerialNumber' : ‘MySerialNumber’,
'AssetModelNumber': ‘MyModelNumber’,
'Others': othersInfoTable,
};
payloadInfoTable.AddRow(payloadInfoTableRow);
// create workorder
var result = Things["PTC.SCA.SCO.AssetService.Connector.ServiceMaxConnector"].CreateWorkOrder({eventInfo: payloadInfoTableRow,alternatePayload:null});