Dynamic Services
The ThingWorx Platform enables you to build scalable solutions using dynamic data services. Dynamic services let you select the entity to execute a service at run time. In Mashup Builder, you can add dynamic services to a mashup using the Add Data dialog box. When you add a dynamic service, the EntityName property appears on the Data panel under the entity name.
EntityName property
Use the EntityName property to specify an entity on which to execute the dynamic service. Each time you change property, it returns a different result when you execute the dynamic service. By contrast, when you add a non-dynamic service, you can only execute it on the current entity.
For example, you add a dynamic service that retrieves data from a sensor Thing to the Data panel. At run time, you assign a different sensor Thing to the EntityName property. This enables you to execute the service for a different sensor Thing without adding to the Data panel. You can bind the dynamic service data to a Chart widget and show.
A Thing can only execute services that are defined or inherited from its template. For example, you can retrieve data from Thing instances defined using a common Thing Template. When you add data, select a Thing Template or Thing Shape that contains all the Things you wish to dynamically assign at run time.
For Example, you can retrieve data from Thing instances that are defined using a common a Thing Template.
1. On the Data panel, click .
a. In the Add Data dialog box, select a Thing Template.
b. Select the GetImplementingThings service.
c. Select the Execute on Load check box, then click Done.
2. Add a Thing instance that is defined by the Thing Template.
a. In the Add Data dialog box, select the Thing entity.
b. Select the Show dynamic services check box.
c. Select the GetProperties service, then click Done.
3. Bind the name property of the SelectedRows data to the EntityName property of the dynamic Thing Template.
You can use the SelectedRowsChanged event in the Data Properties panel to trigger the GetProperties service.
To select an entity name from the GetImplementingThings service, use a List or a Dropdown widget. When the SelectedRows property changes, the GetProperties data service returns data for the specified Thing.
To apply a data filter based on run time values of a returned Thing, use the QueryImplementingThingsWithData service. For more information about this service, see Consuming the Thing Model.
Was this helpful?