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

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education