Get Dynamics 365 field metadata in a Canvas App using DataSourceInfo function | Common Data Service

Mostly, Gallery and Forms are used to work with CDS (Common Data Service) Entities data are in Dynamics 365 like Accounts, Contacts, Opportunities etc.

Some of the common field level metadata info you can retrieve is: MinValue, MaxValue, MaxLength of a field. This is dependent on whether it is supported/provided by Data Source itself, be it CDS or any other Data Source, depends.

You can leverage DataSourceInfo function to enrich your CDS form in a Canvas Power App by showing some metadata about fields. Something like below –

DataSourceInfo function

DataSourceInfo is a function that provides some info about the DataSource itself or the columns present in the Data Source.

Not necessarily all DataSources will provide all information.

In this post, I’m trying to show some metadata of the Dynamics 365 using CDS Data Source.

Microsoft’s official documentation on DataSourceInfo https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datasourceinfo?WT.mc_id=DX-MVP-5003911
In my example, I’ve added some labels to show these values.


MaxLength

MaxLength is used to show the maximum allowed capacity of a field. Most useful to show the maximum length of lengthy fields such as a Multi-line Text Field in Dynamics 365 CRM.

  1. Let’s say Description field in Dynamics 365 has Length provided as 600

  2. I’ve placed maxLen label below the Description field

  3. And the formula is to show the info “Max Length: <value>” is written using Concatenate() function so that I can add some text as I want to make it look more informative.

    In the above formula, in Text() function, I’ve written
    DataSourceInfo in blue. That is the formula that will take arguments like Data Source, DataSourceInfo.<Function> & Column name.
    Accounts marked by showing orange arrow is the Data Source itself since it is connected to Accounts entity in Dynamics 365.
    MaxLength is the attribute which will tell us the Maximum allowed length for the field we will enter next.
    “description” denotes the name of the column in double-quotes of which we want to know the MaxLength.

To enrich this feature, you can use this to dynamically show how much more characters are remaining in real-time as the user types into the field. Refer this post – Implement real-time search in Gallery of CDS records in a Canvas Power App | Power Platform


MinValue & MaxValue

MaxValue & MinValue are used to show the minimum & maximum value allowed in the field. Most apt is having Numeric fields in Dynamics 365 CRM.

  1. Let’s say Grading is a custom field called as Grading which is Whole Number.

  2. I’ve placed minVal and maxVal labels below Grading field in the Canvas Power App.

  3. And the formula is to show the info “Min : <value>” & “Max: <value>” is written using Concatenate() function so that I can add some text as I want to make it look more informative.

    In the above formula, in Text() function, I’ve written
    DataSourceInfo in blue. That is the formula that will take arguments like Data Source, DataSourceInfo.<Function> & Column name.
    Accounts marked by showing orange arrow is the Data Source itself since it is connected to Accounts entity in Dynamics 365.
    MinValue and MaxValue is the attribute which will tell us Minimum & Maximum allowed data values for the field user can enter  in the field in the next parameter.
    new_grading denotes the name of the column in double-quotes of which we want to know the Minimum allowed Value and Maximum allowed Value.

Hope this is useful!

Here are some more Canvas Power Apps posts you might want to check out

  1. Restore older version of a Canvas Power App | Power Platform
  2. Debug Published Canvas Power App with other users using Monitor | Power Platform
  3. Download a File from a Canvas Power App using a button | Power Platform
  4. AddColumns() function to dynamically add columns to a Data table in Canvas Power App | SharePoint List
  5. Implement real-time search in Gallery of CDS records in a Canvas Power App | Power Platform
  6. Log Canvas Power App telemetry data in Azure Application Insights | Power Apps
  7. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  8. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  9. Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists
  10. Aggregate functions in a Canvas Power App | Using on SharePoint Lists
  11. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  12. Correctly connect to an Excel file in a Canvas PowerApp

Thank you!!

One thought on “Get Dynamics 365 field metadata in a Canvas App using DataSourceInfo function | Common Data Service

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.