logo
Documents & Forms
Microsoft 365 & SharePoint Tools
Classic SharePoint Tools
Forms
Sep 05

How to save public forms with file uploads to Dataverse using Power Automate

Customer Support Engineer

In this article, I'll demonstrate how to design a publicly facing web form for collecting data from users outside your organization and saving it directly to Dataverse.

Dataverse is a robust platform for collecting and managing data within the Microsoft Power Platform ecosystem. With its scalable data storage, it's ideal for handling increasing data volumes as your business grows. And whether you're looking to generate new business leads or collect feedback from customers, you'll need an online form to capture their information and a way to save that data from public sources into Dataverse.

Can anyone advise on the best way to get data into Dataverse from a public facing form? I could try MS Forms but would need some transformation into the process. Is there a more efficient direct way?
Post by WebPortal in the Power Platform Community

Imagine this: every company, big or small, needs talented employees. Let's create a job application form and a Dataverse table to manage it all.

In this article:

Create Dataverse table

Let's start by creating a new table in Microsoft Dataverse to store the responses from a public form. This table should include columns that match the fields in the form.

You can create a table from scratch, import data from an Excel/CSV file, or use Copilot.

Tip: Creating a list from a SharePoint list is a preview feature that uses AI to create a table. Be the first to test it! Learn more.

To effectively manage and analyze applicant data, I'll create two custom tables:

  • Job Applications: This table will store information about applicants, including their contact details and resume.
  • Employment History: This table will store information about the applicants' previous job positions.

I'll start with a blank table and create the following columns for the Job Applications table:

  • Applicant Name: Single line of text (primary column)
  • Birth Date: Date and Time
  • Position: Choice column with predefined options
  • Address: Text area
  • Phone: Single line of text (formatted as Phone Number)
  • Email: Single line of text (formatted as Email)
  • Cover Letter: Rich Text
  • Consent: Yes/no
  • Signature: Image
  • Resume: File

The Employment History table include these columns:

  • Applicant Name: Single line of text (primary column)
  • Position: Single line of text
  • Company: Single line of text
  • Hire Date: Date only
  • Leave Date: Date only
  • ParentRowId: Lookup to Job Applications table

And it will have a many-to-one relationship with the Job Applications table:

many-to-one

Tables relationship

Create a public form to fill in data into Dataverse

I'll use Plumsail Forms to create a public web form that applicants can complete online. To save time, I'll start with a ready-made Job Application Form template.

Preview
Theme:
Use this template

 

What's great about this form:

  • Accessibility: Easily accessible via a direct link or embedded on any website.
  • Responsiveness: Fully compatible with tablets and mobile phones.
  • Navigation: User-friendly page layout for easy completion.
  • Data Validation: Ensures accurate email and phone information.
  • Rich Text: Allows for formatted text input
  • Table control: Simplifies adding and organizing work experience with a repeating table.
  • Attachments: Enables file uploads from users outside your organization.
  • Signature: Provides consent to data processing and storage.

For this specific example, this form is sufficient. However, if necessary, you can add more fields and controls to gather extensive data.

Tip: Add a Captcha control to prevent spam, bots, and other malicious activities.

Set up Power Automate Flow to save form submissions to Dataverse

Let's create a Power Automate flow to save public form data to Dataverse.

Open Microsoft Power Automate and create an automated cloud flow. This flow will run automatically when the form is submitted.

Find the Plumsail Forms - Form is submitted trigger, name the flow, and click Create:

flow-set-up

Setup of the automated flow

Log in to your Plumsail Account to create a connection with Plumsail. After that, you'll see a list of your forms in the dropdown. Select the form you want to process in the flow:

plumsail-trigger

Plumsail Forms trigger

Then, add the Microsoft Dataverse - Add a new row action. It will create a new record in Dynamics 365.

add-row

Microsoft Dataverse - Add a new row action

Note: The Microsoft Dataverse actions are part of the Power Automate Premium license.

Select the table name from the dropdown. Once you select the table, you'll see the column names from your Dataverse table. Map your form fields with the corresponding Dataverse columns:

columns-map

Setup of the Add a new row action

That could be it, but Dataverse table have choice and file columns, and the connection to the Employment History table. Saving data to these columns and creating rows in the related table can be a bit tricky. I'll give you some tips and instructions for each case.

Set Dataverse Choice field

Options in a choice column are pairs of integer values and labels:

choice-column

Choice column settings

Tip: You can define different labels for the different languages supported in your environment. This allows you to create Dataverse table forms that are tailored to specific regions or cultures. Learn more.

The actual Dataverse Choice column value is an integer. On a public form the choice field value is a string. The challenge here is to match the value selected on the public form to the corresponding option in a Dataverse table.

That's easier than you can think!

  • Add a Variable - Initialize variable action above the Add a new row action:

initialize-variable

Initialize variable action

  • Name the variable, e.g. Positions_id, set its type to Object and add this object with key-value pairs to the Value box:

      {
          "Account Manager": 218980001,
          "Customer Program Manager": 218980002,
          "Software Engineer": 218980003
      }

    The step must look like so:

    variable-pairs

    Setup of the Initialize variable action

  • In the Add a new row action, for the Position choice column select Enter custom value.

  • Add an expression to retrieve the integer value corresponding to the selected string option from the public form. Go to the Function tab and type: ?[ ]

    expression

    Function tab

  • Go to the Dynamic content tab and add the variable with key-value pairs before the question mark. Inside the square brackets, add the value from the public form.

    Tip: You might need to switch to the classic designer view to see the data in Dynamic content tab.

    The final expression should look like this:

      variables('Positions_id')?[triggerOutputs()?['body/Position']]

     

    expression-final

    Final expression for the choice column

Tip: If you're working with a large number of choice options, connecting the Plumsail Dropdown field to an Excel file can simplify the process. In the Excel file, you can list the labels and corresponding integer values for the Dataverse choice column, eliminating the need for manual configuration.

Save signature to Dataverse Image column

In Plumsail Forms, you can collect signatures from users, such as notes, drawings, or anything else. In this case, with a signature we obtain consent for processing and storing personal data.

The signature, stored in Base64 format, can be easily converted to PNG and saved to the Image column in Dataverse table.

  • Add an Upload a file or an image action after the Add a new row action.

    upload-file-signature

    Upload a file or an image action

  • Select the table and column where you want to save the signature. In the Row ID box, you need to select the ID of the row created in the Add a new row action.

    Type id in the Dynamic Content tab, and select the Unique identifier for the entity instances. The title of the output usually matches the name of the table:

    row-id

    Set up of the Row ID

  • In the Content name box, enter a name for the signature file. It could be a static or dynamic data.

    It's important to enter the correct file extension. In this case, it's PNG:

    content-name

    Content name

  • In the Content box, add this expression to the Function tab:

      dataUriToBinary()

    Then open the Dynamic content tab and add the content of the Signature control from the public form. The final expression should look like this:

    expression-base64-png

    Expression for converting Base64 to PNG

Upload file to Dataverse table row

Just like we saved signatures in Dynamics 365, we can also save files attached to a public form.

  • Add a Plumsail Forms - Download attachment action to get the content of the file attached to the form submission.

    In the File URL box, add url from the Dynamic content tab:

    download-attachment

    Setup of the Download attachment action

    Once you do that, the action will be wrapped inside the Apply to each loop to iterate through each file.

Note: Only one file can be linked using the File column in a Dataverse table. To attach multiple files, create a new table to store attachments. You'll need to create a new row for each attachment and link these rows to the parent row. Keep reading to learn how to create records in the related table.

  • Add a Dataverse - Upload a file or an image action. Select the table and column where you want to save the file.

  • In the Content name box, add file—the output of the Plumsail trigger action:

    file-name

    File name

  • In the Row ID box, select the ID of the row created in the Add a new row action.

    Type id in the Dynamic Content tab, and select the Unique identifier for the entity instances. The title of the output usually matches the name of the table:

    row-id-file

    Setup of the Row ID

  • In the Content box, add Result file—the output of the Download attachment action:

    file-content

    File content

That simple!

Create rows in related table

Now we need to save data from the repeating section of the public form to the Employment History table in Microsoft CRM.

  • Add one more Microsoft Dataverse - Add a new row action and select the Dataverse table where you want to save the data.

  • Map the columns from the form table to the corresponding columns in the Dataverse table. Once you do that, the action will be wrapped inside the Apply to each loop to iterate through each record in the repeating section and create a new row for each line:

    apply-to-each

    Apply to each action

The last is to set the ParentRowId lookup column value, so that new rows will be connected to the row in the primary table. To set the lookup column value we need to know the plural name of the Job Applications table.

  • Open the table in PowerApps, click Tools and Copy set name.

    set-name

    Get the plural name of the table

  • Go back to the MS Flow and paste the set name into the lookup column.

  • Add brackets after the set name and then, add the id of the parent row inside the brackets from the Dynamic content tab.

    Type id in the Dynamic Content tab, and select the Unique identifier for the entity instances. The title of the output usually matches the name of the table.

    lookup

    Set the value of the Lookup column

That's all!

You can follow the same instructions to upload multiple attachments to the Dataverse table row.

Save public form submission to Dataverse table

We've created a Power Automate flow, figured out all the tricks for saving data to Dynamics 365, and it's time to test the flow.

flow

Final flow

I filled out the form with some data and submitted it: filled-form-01

Completed form - Personal Details

filled-form-02

Completed form - Experience

The flow ran successfully, and here is the result in Dynamics 365:

saved-data-01

Data in Dataverse table form - Primary table

saved-data-02

Data in Dataverse table form - Related table

Frequently Asked Questions

How do I save submissions from Microsoft Forms to Dataverse?

To save Microsoft Forms responses to Dataverse, you can create a Power Automate flow following the same instructions for Plumsail forms described in this article. You can also find other posts about saving form data using Power Automate. For instance:

How to set Dataverse Lookup column value in Power Automate?

To update a row in Dataverse table and link to a related table, you need to know the plural name of the parent table. Open the table in PowerApps, click Tools and Copy set name. Use the set name in Power Automate to set the lookup column, like so:

cr19f_setname({Row_ID})

How to attach multiple files to a row in Dataverse?

File and image column allow only one file attached to the row. To connect multiple files, create a table with many-to-one relation and create a row for each file.

How to save signature to Dataverse?

Design a web form in Plumsail and add Signature control to the form. The signature is stored in Based64 and can be converted to PNG using the expression:

dataUriToBinary()

And then, saved to File or Image column in Dynamics 365.

How to set the Dataverse choice column value in Power Automate?

You need to know the option values, which are integers, to set the choice column. If the incoming data is a string, you need to match the string to the corresponding integer value of the choice column.

Use Plumsail Forms to save data to Dataverse

Whether you need to collect data from outside your organization and save it to Dataverse, you won't find a better tool than Plumsail Forms. Its easy-to-use interface, enhanced fields and controls, ability to upload files, and adaptability to any screen size make it a perfect tool for creating publicly facing forms.

Create a free Plumsail account and use one of the ready-made templates to get started easily.

And by following these instructions, you can now create a PowerAutomate flow that will save data from form responses to Dynamics 365. And if you have any questions about flow setup, contact our support team or post in the Plumsail community.