Rename Field Operator
Overview
A Rename Field operator renames the fields, or keys, of data in your application. When you store data on your app, it stores inside data structures called arrays. Arrays then organize your data into fields with unique names to set them apart. You can call or identify your data in an array by referencing its unique name, or Field ID.
Your data can come from APIs (application programming interfaces) or data collection components, such as a Data Table. Unfortunately, field names don’t always read the way you want them to. Sometimes fields have long, complicated names that are difficult to find and reference. Especially if the names are long strings of numbers. The Rename Field operator fixes this problem by letting you rename fields on your app.
You'll find the Rename Field operator under the Table group to the left of your canvas.
What You'll Learn
In this article, you'll learn:
About the Info Window
Here's what the Rename Field operator looks like, along with its Info window:
And here's a breakdown of each setting in the Info window:
Setting |
Description |
---|---|
Category |
Grayed out and non-adjustable setting indicating the operation type. |
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. |
Current Name |
Here you’ll enter the name of the field you want to replace. |
Target Name |
The name you enter here will replace the name you put into the Current Name setting. |
NOTE Current Name and Target Name settings can only have one string, formula, or argument value. The formulas you can use are like the ones used in the Calculator component. For more information on these formulas, search Calculator Formulas in our In-Product Help.
Adding a Rename Field Operator
To show you how the Rename Field operator works, let’s set up an application that renames a Data Table field. You can configure your application to change the field name automatically for the end-user, but let's take a different approach. You'll set this application up so the end-user can enter the field name of their choice.
Here's how the completed use case will look in the Module Builder:
Here's how the completed use case will work in Express View, including a peek at the DevTools Console:
What You'll Need
To set up this use case, you'll need:
-
1 Data Table component
-
1 Text Field component
-
1 Button component
-
1 Data Workflow component
To set up your Data Workflow, you'll need:
-
2 Input operators
-
1 Rename Field operator
-
2 Console operators
Configure the Data Table Component
You'll start by adding a Data Table component. The field names in the Data Table are the ones you'll rename.
1. | Drag and drop a Data Table component onto your canvas. |
2. | Enter dtSampleData in the Label and Property Name fields. |
3. | In the Data Table, enter the following: |
name |
title |
---|---|
Olivia Goodwin |
Aspiring Novelist |
Irene Carline |
Brand Warrior |
Andy Andrus |
Punctuation Prodigy |
4. | Click Save. |
Configure the Text Field Component
Next, you'll use a Text Field to create a place for your end-users to change the field name.
1. | Drag and drop a Text Field component onto your canvas. |
2. | Enter newNameTitleField in the Property ID field. |
3. | Enter New Name for field "title" in the Label Text field. |
4. | Click Save. |
Configure the Data Workflow Component
Then, you'll set up the Data Workflow, which will use the Text Field entry to rename your data field.
1. | Drag and drop the Data Workflow component onto your canvas, placing it below your Text Field. |
2. | Enter dwfRename in the Canvas Label Text and Property Name fields. |
Configure the Input Operators
1. | Drag and drop the first Input operator onto your Data Workflow canvas. |
2. | Configure the first Input operator's Info window with the following: |
Setting |
Value |
---|---|
Category |
Input |
Component |
dtSampleData |
Required |
Yes |
Source |
Default |
3. | Drag and drop the second Input operator onto your Data Workflow canvas. |
4. | Configure the second Input operator's Info window with the following: |
Setting |
Value |
---|---|
Category |
Input |
Component |
newNameTitleField |
Required |
Yes |
Source |
Default |
Configure the Rename Field Operator
1. | Drag and drop the Rename Field operator onto your Data Workflow canvas. |
2. | Configure the Rename Field operator's Info window with the following: |
Setting |
Value |
---|---|
Category |
Rename Field |
Label |
New Title |
Current Name |
title |
Target Name |
_arg |
NOTE You'll connect the Text Field to the argument port (top) of the Rename Field operator. The connection uses the Text Field entries to rename the Current Name data field. To do this, you'll pass the Text Field's argument into Target Name.
3. | Connect the output port (right) of the dtSampleData Input operator to the input port (left) of the Rename Field operator. |
4. | Connect the output port (right) of the newNameTitleField Input operator to the argument port (top) of the Rename Field operator. |
Configure the First Console Operator
You'll want to add a Console operator next. The Console shows your Data Workflow's progress before the Rename Field operator fires. You can see the progress on the DevTools Console.
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 |
3. | Connect the output port (right) of the dtSampleData Input operator to the input port (left) of the Before Console operator. |
Configure the Second Console Operator
Then you'll add a second Console operator. Same as before, you'll use this operator to see your Data Workflow's progress. This Console operator will show you the status after the Rename Field operator fires.
1. | Drag and drop another Console operator onto your Data Workflow canvas. |
2. | Configure the Console operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Console |
Label |
After |
3. | Connect the output port (right) of the Rename Field operator to the input port (left) of the After Console operator. |
4. | Save your Data Workflow. |
Configure the Button Component
Finally, to trigger the Data Workflow, you'll add a Button component.
1. | Drag and drop a Button component onto your canvas. |
2. | Enter btnRename in the Property ID field. |
3. | Enter Rename Field in the Label Text field. |
4. | Set Event as the Action Type. |
5. | Enter dwfRename in the Trigger on Click field. |
6. | Click Save. |
7. | Save your module. |
Nice job! Now that you're finished, you can preview your module in Express View and open the DevTools Console. Enter Career and click the Rename Field button. In the Console, you'll see the before and after of the field renaming.
Changing a Rename Field Operator's Settings
You can revisit and make changes to this operator.
1. | Click the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator to open its Info Window. |
4. | Make changes to the operator's settings as needed. |
5. | Click Save. |
6. | Save your module. |
Copying a Rename Field Operator
You can make a copy of your operator using familiar keyboard settings. You can copy and paste an exact copy of your operator, matching all settings.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator you want to duplicate. |
4. | On your keyboard, press Command + C (Mac OS) or Ctrl + C (Windows/Linux) to copy the operator. |
TIP You can copy more than one operator at a time. Hold Command or Ctrl on your keyboard and click all the operators you want to copy. Follow the rest of the steps as usual.
5. | On your keyboard, press Command + V (Mac OS) or Ctrl + V (Windows/Linux) to paste the copied operator(s) to the Data Workflow canvas. |
6. | Click Save. |
7. | Save your module. |
TIP Did you know you can copy an operator and paste it into a different Data Workflow? You'll use the same steps outlined above.
Removing a Rename Field Operator
Lastly, you can delete this operator from your Data Workflow canvas. You can also use these same steps to delete a connection between two operators.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator you want to delete. |
4. | On your keyboard, press Delete. |
NOTE Once you delete this operator, make sure to connect your remaining operators. If your Data Workflow path doesn't end with an Output or Console operator, your Data Workflow won't work. So, once you delete an operator, make sure to update any remaining paths to end at an Output or Console operator.
5. | Click Save. |
6. | Save your module. |
Lab
You can view this complete use case here: https://training.unqork.io/#/form/60074929f743510215e10aac/edit.