[Power Automate] Parent Cases Flow Configuration
This flow facilitates the migration of Parent Cases from the SQL database to CommCare. The flow is integrated within Power Automate and utilizes multiple components to ensure the accurate transfer and transformation of data.
Flow Components
Trigger: The flow is manually triggered, allowing users to start the process on demand. This trigger is set up as a button in Power Automate, providing flexibility in scheduling migrations.
The following actions are part of the flow:
Get Rows from SQL Database:
Operation: This action retrieves rows from the SQL database, specifically targeting the [dbo].[households] table. It extracts all necessary data fields required for migration.
Connection: The connection is made using a predefined SQL Server connector.
XML Creation Loop:
This loop iterates over each row obtained from the SQL database. For each row, it performs the following actions:
Individual Row Transformation:
Update XML Action: Converts the data into an XML format suitable for CommCare. The XML structure includes essential elements like household_id, location, and case_id. The transformation ensures that each row is correctly formatted and ready for submission.
Paste the Raw XML copied previously for the household registration form submission in the input of the Compose action.
Here's a table format for the XML structure, breaking down each element and its details:
Element | Attribute | Description | Value/Example |
---|---|---|---|
|
| Namespace for CommCare XForms |
|
|
| Namespace for the form designer |
|
|
| User interface version |
|
|
| Form version |
|
|
| Name of the form |
|
|
| Unique identifier for the household |
|
|
| Location information for the household |
|
|
| Namespace for CommCare case transaction |
|
|
| Unique identifier for the case |
|
|
| Date and time when the case was last modified |
|
|
| User ID responsible for the case creation or update |
|
|
| Section defining the creation of a new case |
|
|
| Name of the case |
|
|
| ID of the case owner |
|
|
| Type of the case |
|
|
| Section including updates to the case |
|
|
| Unique identifier for the household (updated) |
|
|
| Location information (updated) |
|
|
| Namespace for form metadata |
|
|
| Device ID used for form submission |
|
|
| Start time of form entry |
|
|
| End time of form entry |
|
|
| Username of the person submitting the form |
|
|
| User ID associated with the form submission |
|
|
| Unique identifier for the form instance |
|
|
| Namespace for application version |
|
|
| Formplayer version used |
|
|
| Time drift indicator |
|
This table outlines each XML element, its attributes, descriptions, and example values. This structured format helps in understanding the composition and purpose of each part of the XML.
These values are dynamically filled into the XML structure using the placeholders @{items('Individual_Row_Transformation')?['FieldName']} where FieldName corresponds to the columns from the SQL database.
Household_ID
Used for:
household_id
n0:case_name
n0:household_id
Location
Used for:
location
n0:location
case_id
Used for:
n0:case attribute case_id
Â
Form Submission to CommCare:
This action submits the XML data to CommCare via an HTTP POST request. The request includes an Authorization key and a predefined URI for the CommCare receiver endpoint. This ensures the data is securely transferred and integrated into the CommCare system.
Â