Deleting data from a Wdata Table is necessary for ensuring Tables stay up to date and that data is not duplicated. In this Connected Learning Path we will walk through the steps to delete data from a Wdata Table using Chains.
Primary Business Use Case |
Table Management |
Primary Learning Objective |
Deleting Data from a Wdata Table using Chains |
Prerequisites |
Complete the CLP | Uploading Data to a Table Path |
Supporting Template |
CLP | Delete Data from a Table |
Step 1: Create a Chain
- Add a new Chain
- Name the Chain: CLP | Delete Data from a Table
- Save the Chain
Step 2: Runtime Inputs
We use the Runtime Inputs Chain Event to kick off the Chain. This allows us to specify the the Table ID and the existing dataset that will be deleted when we run the Chain.
- Add a Runtime Inputs Chain Event from Chain Trigger Events to the Start area
- Edit the Runtime Inputs Chain Event by double clicking on the Command
- Add the Input below:
- Type: TextField
- Display Name: Table ID
- Required: Checked
- Add the Input below:
- Save the Command
Step 3: List File
In order to delete the file in the Table, we will need the File ID. To programmatically find the FileID, we will use the List Files Command. This Command uses the Table ID to search for all of the files within that Table and provides us with an output of the files as well as information about those files, including the File ID.
- Add a List Files Command to the Chain canvas
- Connect the Runtime Inputs Chain Event to the List Files Command
- Double click the Command to configure it
- Click on the Table ID field
- Within the left Variables panel, click the down arrow to expand Trigger
- Click the down arrow to expand Runtime Inputs
- Select TableID
- Click on the Table ID field
- Save the Command
Step 4: Un-Import File from Table
Similar to uploading data to a Table, deleting data from a Table is a two step process. The file will first have to be moved to the staged status before it can be deleted. To set the file as staged, it will need to be unimported. We will use the Un-Import File from Table Command to prepare the dataset to be deleted.
- Add an Un-import File from Table Command to the Chain canvas
- Connect the List Files Command to the Un-import File from Table Command
- Double click the Command to configure it
- Click on the Table ID field
- Within the left Variables panel, click the down arrow to expand Trigger
- Click the down arrow to expand Runtime Inputs
- Select TableID
- Click on the File ID field
- Within the left Variables panel, click the down arrow to expand List Files
- Select Files List
- Click on the List Files - Files List variable to transform the variable
- Click Select Transformation and then select Get Value from JSON
- Click the plus sign to add the variable transformation
- In the Value field type '0' and then hit enter. After the =0 appears, type 'id' and hit enter again. The variable will now read the JSON output from the List Files command and find the id of the first file in the table.
- Click on the Table ID field
Tip! Pay special attention to upper case vs lower case when parsing JSON
-
-
-
-
-
- Click Accept
- Click Accept
-
-
-
-
-
-
- Save the Command
Step 5: Delete File
Now that the dataset has been staged, the final step is to officially delete the data. This step uses the Delete File Command to delete the dataset from the Table.
- Add a Delete File Command from the Workiva Connector to the Chain canvas
- Connect the Un-import File from Table Command to the Delete File Command
- Double click the Command to configure it
- To ensure we are deleting the same file that we un-imported, we will generate the file ID the same way as we did for the Un-import File from Table Command, as outlined below:
- Click on the File ID field
- Within the left Variables panel, click the down arrow to expand List Files
- Select Files List
- Click on the List Files - Files List variable to transform the variable
- Click Select Transformation and then select Get Value from JSON
- Click the plus sign to add the variable transformation
- In the Value field type '0' and then hit enter. After the =0 appears, type 'id' and hit enter again. The variable will now read the JSON output from the List Files command and find the id of the first file in the table.
Tip! Pay special attention to upper case vs lower case when parsing JSON values
-
-
-
- Click Accept
- Click Accept
-
-
- Save the Command
Step 6: Test the Exercise
Now that the Chain is complete, test the result.
- Publish the Chain
- Click Execute and then select Run With Inputs
- Add values for your Runtime Inputs
-
Table ID of the CLP | Employee Details Table
- If your Table does not have data in it yet, be sure to run the CLP | Upload Data to Table Chain
-
Table ID of the CLP | Employee Details Table
- Click Start
- Once the Chain has completed, click the Delete File node to verify success
- The Chain should have successfully taken your file, un-imported it, an deleted it from your Table
- You can verify the data was deleted by navigating to the Table in Wdata and reviewing the Datasets panel on the right
To learn more about managing Datasets in Wdata tables using Chains, check out the next path: Replacing Data in a Table!