Create Field Operator
Overview
The Create Field operator is a multi-purpose operator. At the simplest level, it does what its name suggests: creates fields. But, you can also use the Create Field operator to:
-
Dynamically add key/value pairs based on your end-user's End-users, also known as Express Users, are the individuals accessing an application through Express View. In most cases, end-users are the customers using the product. input.
-
Add key/value pairs with values based on the value of another field. For example, creating a field with a value calculated using the value from another field.
-
Add key/value pairs with a conditional value. For example, adding one of two possible values, based on a conditional if/then expression.
-
Update existing fields in a Data Table.
You'll find the Create Field operator in the Table group in the menu on the Data Workflow canvas.
What You'll Learn
In this
Info Window Settings
Here's what the Create Field operator looks like, along with its Info window:
And here's a breakdown of each setting in the Info window:
Setting |
Description |
---|---|
Label |
Sets the label for your operator. The label you enter here shows beneath your operator on your Data Workflow canvas. This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows. |
Do Not Sanitize Formula |
When this checkbox is clear, the operator does its best to clean up values coming into or defined in the operator. For example, removing special characters. Some of those special characters include ', $, #, &. The operator also cleans up complex values. For example, logically breaking up strings of numbers and letters using underscores. A sample module ID can go from "5f6b4cdfabf886024d4de2d3" to "5f_6b_4cdfabf_886024d_4de_2d_3". Sanitizing improves performance. But, it can also lead to unexpected data behavior. If your Create Field isn't behaving as expected, try selecting this box. When selected, the operator uses your values and expressions as-is. This is best when working with complex values or values that should remain unchanged. By default, this setting is selected, which means the operator doesn't attempt to sanitize. |
Preserve Argument Type |
When selected, this setting ensures the argument data type is respected when the operator executes. |
Field 1-5 |
Notice how the Create Field operator has 5 different Field options. This means you can add multiple fields using a single operator. Define the field you want to create or update, using the following format: key=value. For string values, add single or double quotes around the value. For example, employed="yes". The value part of the key=value expression can also include calculations, conditional expressions, and references to other fields. It can also reference values coming into the argument port, using the alias _arg. For example, this expression that uses a calculation: incomeMonthly=_arg/12. The calculation happens on the input coming into the operator's argument port. Or this one, that includes a conditional expression, a reference to another field, and a calculation:lowIncome=IF(incomeAnnual<24000,"yes","no"). Conditional expressions should use the following format: key=IF(condition,valueIfTrue,valueIfFalse). |
Adding and Configuring the Create Field Operator
Next, you'll learn how to use the Create Field operator. Here, you'll see how to add the same key/value pairs to every row in a table.
NOTE These instructions assume that you have a new module open, saved, and with a title.
Here's how the completed use case looks in the Module Builder:
Here's how the completed use case works in Express View Express View is how your end-user views your application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View., including a peek at the final table in the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.:
Configure the Data Table Component
First, add a Data Table to hold your key/value pairs.
1. | Drag and drop a Data Table component onto your canvas. |
3. | In the data table, enter the following: |
A | B | |
---|---|---|
1 |
Cammy |
32 |
2 |
Josephine |
41 |
3 |
Ammie |
22 |
4. | Click Save & Close. |
Configure the Data Workflow Component
With the Data Table set up, you're ready to use the Create Field operator to add two new key/value pairs to each row.
1. | Drag and drop a Data Workflow component onto your canvas, placing it below your Data Table component. |
2. | In the Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the . and Property Name fields, enter dwfCreateField. |
Configure the Input Operator
Start by connecting your Data Table to the Data Workflow using an Input operator.
1. | Drag and drop an Input operator onto your Data Workflow canvas. |
2. | Configure the operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Input |
Component |
dtTable |
Required |
Yes |
Source |
Default |
Configure the Create Field Operator
Next, set up the Create Field operator. This operator adds two new key/value pairs to each row (object) of your table (array).
1. | Drag and drop a Create Field operator onto your Data Workflow canvas. |
2. | Configure the operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Create Field |
Label |
employment |
Do Not Sanitize Formula |
Unchecked (no) |
Preserve Argument Type |
Unchecked (no) |
Field 1 |
insured="yes" |
Field 2 |
renewalYear=2023 |
3. | Connect the output port (right) of the Input operator to the input port (left) of the Create Field operator. |
Configure the First Console Operator
Console operators give you a look inside the action of your Data Workflow. This Console operator shows your data before adding your key/value pairs.
1. | Drag and drop a Console operator onto your Data Workflow canvas. |
2. | Configure the Console operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Console |
Label |
Before Create Field |
3. | Connect the output port (right) of the Input operator to the input port (left) of this first Console operator. |
Configure the Second Console Operator
This Console operator shows your data after adding your key/value pairs.
1. | Drag and drop another Console operator onto your Data Workflow canvas. |
2. | Configure Console operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Console |
Label |
After Create Field |
3. | Connect the output port (right) of the Create Field operator to the input port (left) of the After Create Field Console operator. |
4. | Click Save. |
Configure the Button Component
Finally, add a Button to trigger your Data Workflow.
1. | Drag and drop a Button component onto your canvas, placing it below your Data Workflow. |
2. | In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. field, enter btnRunDWF. |
3. | In the Label Text Label Text conveys what the input component is and what information it displays. Enter the purpose of the corresponding component or field. field, enter Run Create Field. |
4. | Set the Action Type to Event. |
5. | In the On Click field, enter dwfCreateField. |
6. | Click Save & Close. |
7. | Save your module. |
Now, test your Data Workflow. Preview your module in Express View and open the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.. Click the Run Create Field button and see what displays in the DevTools Console:
Resources
-
You can view this complete use case here: https://training.unqork.io/#/form/5f6e280419c4e6024ed26702/edit.
-
Modify the Create Field operator in the Data Workflow's configuration window.