Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Below shows how we can create the GetCustomerPackages Service for the PTCDeliversBusinessLogic Thing.
/ Provide your filter using the format as described in the help topic "Query Parameter for Query Services" var query = { "filters": { "type": "EQ", "fieldName": "CustomerId", "value": CustomerId } }; // result: INFOTABLE dataShape: "" var result = Things["PackageDataTable"].QueryDataTableEntries({ maxItems: undefined /* NUMBER */, values: undefined /* INFOTAB
After saving changes and closing the Service edit view, you can test the method by selecting the Execute play button.
The Service we created will query PackageDataTable for any packages with the CustomerId you entered. If no data has been added to the DataTable as yet, open PackageDataTable's Services tab and execute the AddDataTableEntries Service with test data.
Subscriptions are based on tracking the firing of an Event. When the Event is triggered or fired, all entities with a Subscription to the Event will perform the script as defined. The JavaScript interface and script tabs are the same as those utilized for the Services interface.
Subscriptions are a great resource for making updates in other Entities, Databases, or even just logging this information to your liking.
/ tags:TAGS
var tags = new Array();
// values:INFOTABLE(Datashape: PackageDataShape)
var values = Things["DeliveryDataTable"].CreateValues();
values.Customer = eventData.Customer; // THINGNAME
values.Content = eventData.Content; // STRING
values.ID = eventData.ID; // INTEGER [Primary Key]
values.Weight = eventData.Weight; // NUMBER
// location:LOCATION
var location = new Object();
location.latitude = 0;
location.longitude = 0;
location.elevation = 0;
location.units ="WGS84";
var params = {
tags : tags,
source : me.name,
values : values,
location : location
};
// AddOrUpdateDataTableEntry(tags:TAGS, source:STRING("me.name"), values:INFOTABLE(DeliveryDataTable), location:LOCATION):STRING
var id = Things["DeliveryDataTable"].AddOrUpdateDataTableEntry(params);
Congratulations! You've successfully completed the Implement Services, Events and Subscriptions guide.
In this guide you learned how to to create Events, Services and Subscriptions you can utilize to monitor and optimize your IoT applications.
The next guide in the Design and Implement Data Models to Enable Predictive Analytics learning path is Build a Predictive Analytics Model.
The next guide in the Monitor Factory Supplies and Consumables learning path is Build a Predictive Analytics Model.
We recommend the following resources to continue your learning experience:
Capability Guide
Build | Create Custom Business Logic Guide |
Secure | Configure Permissions |
Connect | SDK Reference |
If you have questions, issues, or need additional information, refer to:
Resource Link
Community | Developer Community Forum |
Support | Help Center |