Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Discover how ThingWorx Functions can be implemented in a compelling Mashup design.
This project will introduce how to create complex user interfaces that are built by using simple Mashup functions.
Following the steps in this guide, you will build a web application with multiple layers.
We will teach you how to create a professional user interface that effectively conveys information to users.
NOTE: This guide's content aligns with ThingWorx 9.3. The estimated time to complete ALL parts of this guide is 60 minutes
In the Mashup Builder, we utilize Functions to create added capabilities in our Mashups. Whether we are navigating to another Mashup or triggering events based on some action. Functions are your best friends when creating more advanced Mashups.
Function | Description |
Auto Refresh | Refreshes data automatically for widgets in a mashup. |
Confirmation | Displays a confirmation dialog box. |
Events Router | Routes multiple input sources to one output of the same type. |
Expression | Evaluates JavaScript expressions. |
Logout | Ends the current user session and redirects to a mashup or a Web page. |
Navigation | Navigates from one mashup to another. |
Status Message | Displays information, error, or warning messages in a mashup. |
Validator | Validates data from input parameters by using JavaScript expressions. |
In the next sections, we will cover some of these Functions and showcase how to add them to your Mashups.
Let's start things off by creating a simple Expression Function. This Expression will show or hide a label based on whether a checkbox is checked or not. This simple expression can be expanded to your use case.
It is VERY important to note that in an Expression Function (and also found in Services and Validation Functions) the output of the Function will be the result variable. Let's create our Mashup, then go over what is involved in an Expression.
Select Mashup in the dropdown.
This Mashup will be where we create the Majority of our Functions and capabilities. Let's start adding to our Mashup.
We have the Widgets we need to show our Expression example. Let's start with connecting the Widgets to Functions.
if(checked) { result = true; } else { result = false; }
11. Click Done.
You've now created your first expression. This expression is an example of how easy it can be done. Let's add three three additional Expressions to have some fun.
if(checked) {
if(input && input.indexOf("YES") >= 0) {
result = input + ", YES";
} else {
result = "YES";
}
} else {
result = "NO";
}
6. Click Done.
This expression will see whether or not the Checkbox is checked, then output a string of YES or a simple NO. Let's setup our connections between Widgets and Expressions.
Our labels are configured. Now let's setup our Text Field Widget.
You may notice that both Label Widgets show or hide at the same time. To split when they will show or hide, update the code for one of the Label visibility Expressions to the following:
if(checked) {
result = false;
} else {
result = true;
}
Click here to view Part 2 of this guide.