defining datasources tables and fields in data connectivity code guide

Defining DataSources, Tables, and Fields in Code Projects: A Comprehensive Guide

Understanding the intricacies of a code project can often be challenging, especially when it comes to identifying where datasources, tables, and field definitions are defined. This comprehensive guide delves into this topic and provides insight into the structure and modification of these definitions, using the example of a SharePoint connection with Power Apps.

If at any point you find yourself needing additional technical assistance, feel free to contact us. Our team is always ready to support and guide you through your queries.

Understanding the Project Structure

Upon accessing the code project, there are primarily three folders pertaining to data connectivity:

  • Connections: This directory contains a file named Connections.json, which houses a JSON representation of the app’s connections like SharePoint, SQL Server, and others.
  • DataSources: Within this directory, there’s a separate JSON file for every data source associated with the app. For instance, for a connection to a SharePoint list titled “property”, there would be a file named Property.json explaining the list’s schema.
  • Pkgs > TableDefinitions: This sub-directory holds a JSON table definition file for every datasource related to the app. Using the same example, another Property.json file can be found here, detailing the list schema even further.

Finding Detailed Table Definitions

Accompanying every JSON file in the DataSources folder, there’s a matching JSON file inside the Pkgs > TableDefinitions directory. This particular file elaborates on the table’s definition in more detail. The core segment of this file includes a “DataEntityMetadataJson” section containing a string-escaped definition of the table. This section presents valuable details like:

  • Sortable and filterable field names identified by the x-ms-capabilities node.
  • Filter functions that the data source supports, as highlighted in the filterFunctionSupport node. In our SharePoint example, this comprises functions like “and”, “or”, “equals”, and “startswith”.
  • An array detailing the column names in the schema section. Every array element describes the column name, data type, writability, acceptable value range, and the operators that the column supports.

Demonstration: Modifying a Column’s Data Type

To showcase the modification process of a column’s data type, consider the AquisitionPriceUSD column in our SharePoint list. Power Apps previously misinterpreted SharePoint’s numeric calculated columns as strings, making it difficult to employ numeric formatting or utilize screen controls intended for numbers. However, by editing the data type of this column to:

{
  "title":"AquisitionPriceUSD",
  "type":"number",
  "format":"double",
  "x-ms-permission":"read-only",
  "x-ms-sort":"none"
}

and then repackaging our project with the PSAopa command, Power Apps now correctly identifies the AquisitionPriceUSD column as numeric. Do note that refreshing the data source via the designer will revert any changes made, setting the AquisitionPriceUSD column’s data type back to string.

Conclusion

Navigating the intricacies of a code project, especially in relation to data connectivity, is pivotal for developers. This guide shed light on the specific locations and methods to identify and modify data sources, tables, and fields within a code project. By understanding the structure and knowing how to tweak it, developers can ensure that tools like Power Apps function optimally. If you ever find yourself stuck or need further clarity, do not hesitate to reach out to us. We’re here to help!

About The Author