Importing submission data into the Power Automate ecosystem will allow you to connect Device Magic to 500+ apps. The methods described in this article can be applied to all supported Power Automate connectors you wish to use in your automated workflows.

Creating the JSON to OneDrive Destination

Create a JSON to OneDrive destination for your form in Device Magic

In step three, specify images are stored in another service. This setting will place a link to the associated image in the generated JSON.

Enter a folder path in step six. A flow in Power Automate will reference this folder in a later step.

If you're sending binary files to OneDrive as well, enter a different folder path value in step seven. Be sure to also set the appropriate link settings.

After creating your destination, submit a form so the JSON is placed in OneDrive. Navigate to OneDrive in your browser and view your JSON.

Creating the Automated Cloud Flow in Power Automate

Adding the Trigger

From here, navigate to Power Automate. Click Create and select Automated cloud flow.

Enter a Flow name of your choice, select When a file is created (OneDrive for Business), then click Create.

Select the first folder path you specified previously.

Adding the Compose Step

Click + New Step and select Compose (Data Operation). In the Inputs text box, select Expression in the menu that appears on the right side of the page. Then, enter base64ToString(triggerBody()?['$content']) and click Okay.

Adding the Parse JSON Step

Click + New Step and choose Parse JSON. Select the text box for Content and choose Outputs in the menu that appears on the right. Navigate to your OneDrive folder containing the JSON. Open the file, select all and copy. Go back to Power Automate and select Generate from sample. Paste the previously copied JSON into the text box. The schema is then generated automatically.

A note regarding optional answers inside subforms.

When a value in a subform may or may not be included in a submission (not required), remove it from the required values for the particular subform. This will prevent any errors that appear when an optional value isn't present in the JSON.

Optional answers outside of subforms will be addressed through expressions in the next step.

Mapping Form Answers

Click + New Step and select Create item (SharePoint). Select the Site Address of your list and the List Name. Your SharePoint list will need to exist prior to this step.

Note: If you wish to use another app other than SharePoint, select it and apply the same steps.

Metadata (ex. submission id) - These should be automatically available for selection.

For a value not available for selection, define that Power Automate access the body of the output generated by the Parse JSON step and extract the value. Do the following to accomplish this.

  • Select Expression

  • Enter outputs('Parse_JSON')['body']['answers'][QUESTION_IDENTIFIER]['value']

  • Replace QUESTION_IDENTIFIER with the identifier of your question. Confirm the identifier in the JSON placed in OneDrive.

For questions nested in groups, follow the JSON structure and add the required keys.

For example, to extract the value of the Observed_Safe_Behaviors question inside of subform Observed_Behaviors, the expression would be outputs('Parse_JSON')['body']['answers']['Observed_Behaviors']['values'][0]['Observed_Safe_Behaviors']['value']. Note the values key and index 0 required to access the object.

Optional questions in your form

For questions that may or may not have an answer when submitted, you'll want to do the following. At a high level, this expression checks if your question's identifier is present in the output of the Parse JSON step. When true, the value is the question's answer. When false, null. Adding this expression for optional questions will help prevent any errors so your flow runs smoothly.

if(contains(outputs('Parse_JSON')['body']['answers']['Last_Oil___Filter_Change_Info']['values'][0],'Oil_Change_Invoice'),outputs('Parse_JSON')['body']['answers']['Last_Oil___Filter_Change_Info']['values'][0]['Oil_Change_Invoice']['value'], null)

To test, submit a form as you did in step 1. When the flow is triggered, a new row will be added to your Sharepoint list.

For questions or comments please send us a message at support@devicemagic.com.

Did this answer your question?