Skip main navigation

Creating and Updating Data

.

In the previous step, you learnt about querying data. Using Get Record, List Record and Filter Queries retrieve data at a specific point in time. Now you will learn about creating and updating records.

The Common Data Service (CDS) Create Record and Update Record actions are commonly used to create and modify CDS data.

These actions are key to automating work within the platform. In this topic, we will cover some of the considerations when using these actions.

Once you have selected an entity the action will list the fields that are available. They are not listed in alphabetic order so keep scrolling down if you don’t see the name you are looking for. In fact, you might have to click Show Advanced to see all the fields.

When setting fields take care to ensure the data you are providing is in the correct format.

Text Fields – if you are specifying a fixed value do not include quotes; it will store the quotes with the data.

Number Fields – if you are specifying a fixed value, they must be free of any commas or quotes. This will be detected by the editor if you type them in but will fail at runtime if you bind to data fields that contain commas. If the field allows decimal points, they are ok, otherwise if you try to pass a decimal point to a whole number field it will fail at runtime because flow does not do data conversion.

Currency – remember that when you set this field it will be assumed to be in the organisation default currency unless you also set the currency lookup field on the record. To set other currencies you would need the Globally Unique Identifier (GUID) for that currency.

Lookup Fields – if you are populating a lookup field (N:1) you need to provide the GUID for the record you are relating to. If you don’t have the ID, you would first retrieve the record using the data you have, and then use the primary attribute ID to build the relationship.

Date Fields – dates must be in Universal Coordinated Time (UTC). If you pass another time zone value it will still be stored in CDS as UTC without any conversion and be incorrect. If you need to specify a fixed date it must be in the format of yyyy-mm-ddThh:mm:ssZ. There are several ways to work with dates that we cover in another topic.

Option Set Values – each option set field will have a drop down containing the available values. Alternatively, you can select Enter Custom Value and provide the numeric value for the option. The most common reason to provide a custom value is if you are binding to a variable or field from another step.

Owner Fields – by default user/team owned entity records created will be owned by the user associated with the Connection specified on the Action. You can modify the owner by providing the GUID for a user or team. You must also select User or Team in the Owner Type field when making this change.

Creating Records

When using the Create Record action make sure you provide the minimum required fields to create the record. Remember the minimum fields can be influenced by business rules, CDS classic workflows and developer plug-ins that have been built to enforce required field contents.

Updating Records

Only set the fields that you intend to update with changed values when performing an Update action. If you specify fields that have the same value, it will still be treated as a change for purposes of audit and triggering of other automations. This can cause other automations to run without having actual values changed.

You are required to provide the item identifier for the record you are updating. This is the GUID of the record. If you provide a GUID that isn’t an existing record, the Update action will create a new record with that GUID.

To clear a field of the existing stored value set the field to null. You can do this by typing null as an expression in the Dynamic content panel.

Screenshot of clearing a field by setting it's value to null

Take care to make sure you don’t clear fields by accident simply by binding to a property that does not have data causing you to inadvertently set the field to null.

Make sure when you use Create and Update on the same entity that triggered the flow that care is taken to not create a loop with your action re-triggering the same flow. The best way to prevent this is to always set attribute filters and to avoid working with the same entity if possible.

This article is from the free online

Dynamics 365: Working with Power Platform Automation

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now