Optimize Power Apps: Patching Dataverse Columns
Power Apps
Jan 4, 2024 11:00 PM

Optimize Power Apps: Patching Dataverse Columns

by HubSite 365 about Craig White

Talks about #lowcode, #formula1, #powerplatform, #empoweringothers, and #digitaldisruption

External YouTube Channel
Citizen Developer

Power AppsLearning Selection

Master Dataverse Column Patching Techniques with Power Apps!

Key insights

 

Patching Complex Dataverse columns in Power Apps is essential as transitioning from SharePoint lists to Dataverse tables becomes more common. The column types in Dataverse may have the same names, but the patch techniques are significantly different. This article aims to guide the patching of single choice, multiple choice, lookup, and yes/no fields in Dataverse, noting the unique characteristics of each column type.

  • Understanding Dataverse Columns: Dataverse offers a 'Choice' field type with the option to sync with global or local choices, affecting how the field values are utilized across tables and solutions. When patching, both single and multiple choice columns use a global choice set and involve different patching techniques.
  • Working with Lookup Columns: Lookup columns are similar to SharePoint's, where a specific table is referenced but with a distinct way of accepting and using the data. It's crucial to correctly reference the entire record for a successful patch.
  • Handling Yes/No Fields: Although yes/no fields in Dataverse are similar to boolean data types, they actually function as a predefined choice set. While a control is typically needed to patch data, boolean values can also be directly patched to this column type.
  • Patching Person Fields: Unlike SharePoint, Dataverse doesn’t have a 'Person or Group' column. Instead, a lookup column that points to a table such as Microsoft Entra ID is used to simulate this functionality. When patching, the complete user record is necessary.
  • Practical Tips for Patching: The article provides code snippets and method explanations to patch Dataverse columns effectively using Power Apps. Also discussed are the implications of patching multiple choice columns and handling hard-coded values.
 

Understanding Patching for Dataverse Columns

Patching complex column types in Dataverse is an essential skill for Power Apps users, as it allows for the customization and management of data within applications. This process entails transferring changes or updates from your Power Apps' user interface to the underlying Dataverse database. As Dataverse becomes a more common destination for data migration, especially from SharePoint, knowing how to manipulate its different column types—such as single and multiple choice items, lookups, and yes/no fields—is crucial.

It's important to note that while Dataverse shares some similarities with SharePoint, the methods for patching differ, requiring users to adapt their approaches. For instance, Dataverse has unique ways of handling choice sets and does not support a direct 'Person or Group' column type. Through a combination of dropdowns, combo boxes, and precise Power Fx code, users can effectively manage complex column types. Craig White's tutorial serves as an invaluable tool for those looking to master these techniques and optimize their use of Power Apps with Dataverse.

Patching Complex Dataverse Columns With Power Apps

Following the article on patching complex column types in SharePoint, I explored the adaptation of these methods for Dataverse. Transitioning from SharePoint lists to Dataverse tables is prevalent, and it’s crucial to grasp the distinct patching techniques required for different column types. While both feature similar column types, the techniques applied in Dataverse are unique and essential to learn.

This article delves into how to patch various field types like single choice, multiple choice, lookup, and yes/no fields in Dataverse. Notably absent is the ‘Person or Group’ column found in SharePoint, but there are alternative methods to handle similar functionality.

Setup

The explanations provided are supported by a Dataverse table I created known as Patch Complex DVS. For those who are newer to Dataverse, the table setup process may seem different. Therefore, I will elaborate on this aspect further.

Choice Sets

When adding a 'Choice' field type in Dataverse, you are presented with an option of syncing with a global choice or not. Global choices are advantageous when consistent options are needed across multiple environments. Alternatively, local choices are specific to the table and column at hand.

If you opt out of using a global choice, you can immediately add custom entries. This simplicity mirrors the process of setting up a SharePoint choice column. If you choose to use a global choice, you can either select an existing set or create a new one. These distinctions are key when patching these column types, a topic I will cover shortly.

Choice Columns

For exemplification, I created two choice columns, 'ChoiceSingle' and 'ChoiceMulti.' Both columns utilize the same global choice set, with the only difference being that the 'ChoiceMulti' column has multiple selections enabled.

Lookup

Lookup columns in Dataverse operate similarly to SharePoint. You choose the table to look up to and configure it accordingly. In my example, I used the Account table with some mock entries to demonstrate how this works.

Yes/No

Yes/no fields in SharePoint take boolean values. Interestingly, in Dataverse, despite appearing like a choice column with preset 'yes' or 'no' options, they can still accept boolean values when patching.

Person

Although there's no direct 'Person or Group' column in Dataverse, we can replicate this functionality through a lookup column directed towards the Microsoft Entra ID table (previously known as AAD Users). However, this will only accept a single person, with no option to include multiple users.

Consideration for a solution that supports a multi-person picker within Dataverse applications is underway, with a detailed discussion expected in an early 2024 article.

Handling Single and Multiple Choice Columns

For the 'Single Choice' column, a drop-down control named 'dpdChoiceSingleDV' is adjusted to ensure that it binds to the choice set created. The 'Items' property of this control then aligns with the global choice set, allowing the proper value to be patched.

For 'Multiple Choice,' a combo box named 'cmbChoiceMultiDV' follows a similar setup, referencing the relevant choice set and using 'SelectedItems' for patching since it involves multiple values.

Lookup and Person

In both these cases, the fundamental logic is connected to combo box controls named 'cmbLookupDV' and 'cmbPersonDV' respectively. The selected record from these controls helps patch the relevant columns in Dataverse.

When no controls are utilized, manual lookups to the correct table are necessary, ensuring the specific or entire record is fetched for patching.

Yes/No

To address Yes/No columns, a drop-down named 'dpdYesNoDV' is used. Direct referencing of the control with '.Selected.Value' allows the chosen value to be patched. However, direct boolean values are also an acceptable method to patch these types of columns.

The intricacies of patching complex Dataverse columns with Power Apps require attention to the unique properties and limitations of the system. These detailed explanations serve as a guide for those familiar with SharePoint looking to make the switch to Dataverse efficiently.

Patching a Lookup Column

Use this method to update a lookup column by providing a record reference.

Patch(
	YourDataSource,
	YourRecordReference,
	{
		'LookupColumnName': LookUp(OtherDataSource, ConditionToIdentifyRecord)
	}
);
	

Patching a Choice Column

For a choice column, provide a record with a specific structure.

Patch(
	YourDataSource,
	YourRecordReference,
	{
		'ChoiceColumnName': { 
			'Value': "YourChoiceValue" 
		}
	}
);
	

Patching a Multi-Select Choice Column

Multi-select choice columns require an array of choice values.

Patch(
	YourDataSource,
	YourRecordReference,
	{
		'MultiSelectColumnName': {
			'Value': [
				{ 'Value': "Choice1" },
				{ 'Value': "Choice2" }
			]
		}
	}
);
	

 

Read the full article Patch Complex Dataverse Columns With Power Apps

Power Apps - Optimize Power Apps: Patching Dataverse Columns

 

People also ask

How do I Patch a Dataverse LookUp column in Power Apps?

To patch a Dataverse LookUp column in Power Apps, use the syntax Patch(DataSource, Defaults(DataSource), {LookUpColumnName: LookUpValue}). The LookUpValue should be a record reference to the related entity that you want to link to.

How do I update Dataverse table in Power Apps?

Updating a Dataverse table in Power Apps can be done using the Patch function. Specify the table as the data source, the record to be updated, and provide a record with the updated values. For example: Patch(TableName, RecordRef, {Column1: Value1, Column2: Value2}).

What is the Patch function to update Dataverse table?

The Patch function is used to create or modify records in a Dataverse table. Its basic syntax for updating a table is Patch(DataSource, Item, Changes), where DataSource is the table name, Item is the record you want to update (can be a reference or an existing record), and Changes are the new values for the specified fields in the form of a record.

How do you update data using Patch function in Power Apps?

To update data using the Patch function in Power Apps, you define the table you want to modify, identify the specific record to update, and specify the changes. It looks like this: Patch(DataSource, Record, {FieldName: NewValue, AnotherField: AnotherNewValue}). This will update the fields of the record in the DataSource with the NewValues you provide.

 

Keywords

Dataverse Patch Function, Power Apps Column Update, Power Apps Dataverse Integration, Update Complex Columns PowerApps, PowerApps Dataverse Patch Method, Complex Column Types Patching, Patch Multiple Columns PowerApps, Power Apps Data Patch Technique, Complex Entity Patch PowerApps, PowerApps Dataverse Field Update