All Content
Timespan
explore our new search
Using FetchXml in Custom Pages Without Flows - PCF Method
Image Source: Shutterstock.com NetForce 365
Developer Tools
Oct 20, 2022 8:08 AM

Using FetchXml in Custom Pages Without Flows - PCF Method

by HubSite 365 about Diana Birkelbach [MVP]

Dianamics PCF Lady | Microsoft MVP | Blogger | Power Platform Community Super User | 👩‍💻 Dynamics 365 & PowerPlatform Developer | ORBIS AG

Citizen DeveloperDynamics 365Developer ToolsM365 Hot NewsMicrosoft Dataverse

Discover an efficient workaround to call FetchXml inside custom pages without flows on complex fetchXmls & CustomAPIs - the PCF way.

Written by Diana Birkelbach [MVP], this blog post explores how to fetch complex data from Dataverse using Power Fx and Power Automate inside a Custom Page, in both Canvas Apps and Custom Pages scenarios. Through an enhanced reliance on Power Apps Component Framework (PCF), an innovative and more streamlined approach was developed for Custom Pages.

This developed method includes the use of PCFs without UI, which are designed solely for making a fetchXML request. These "technical PCFs" can make WebAPI calls, fetching data through two ways. The first way uses the PCF to retrieve data based on a fetchXML, returning the result as a JSON string. The second way makes use of a PCF to fetch data, but the result forms a dynamic output "object".

For more detailed guidance on the use of PCFs in this manner, you can check here.

The Use-case

The demonstration centers around an example use-case: obtaining a count of activities for all accounts, grouped by industryCode. This process entails use of the FetchXML Builder by Jonas Rapp, and converting the result to a JSON-Web API Format.

All code work is easily executed, and upon completiton, the converted fetchXML request to JSON will be visible. The 'FetchRecords' function makes use of webAPI to execute the request, which reference lines of code serve to spotlight.

Alternative ways to extrapolate data such as a string method could also be employed. The output of such methods must be integrated into 'getOutputs' for them to function effectively.

It should be noted that a Custom Page designer does not support WebAPI code, but Power Apps Runtime does. Nonetheless, the designer can still function with a work around involving 'catch' for feedback and returned schema handling.

The Custom Page

In making use of the the Custom Page, different attributes like the fetchXML and entityName are assigned through text boxes. The PCF, in this case, provides an empty 'divider'. Under CustomPage settings, experimental features such as 'Named formulas' and 'ParseJSON function and untyped objects' are activated.

A named formula 'FetchResult' is utilised, which appropriates 'ParseJSON' onto the PCF output, reviews the array and filters the specific properties necessary. This allows a gallery to be added to FetchResult, displaying its defined properties.

A user-friendly Designer, backed by intelligent software, aids in the design of the gallery. In this example, the designer also expertly handles the properties and Intellisense assistance. Hereby, the results display the number of activities established for each IndustryCode.

All code for this PCF is available on the official GitHub page of the author. However, the complete Custom Page set-up is housed inside the Demo_CustomPages folder, which includes additional references to App.fx.yaml and Screen.fx.yaml.

Read the full article Call FetchXml Inside Custom Pages Without Flows – The PCF Way

Developer Tools - Using FetchXml in Custom Pages Without Flows - PCF Method

Learn about Call FetchXml Inside Custom Pages Without Flows – The PCF Way

Microsoft being known for its extensive range of developer tools and applications also offer Custom Pages as a developmental feature that allows developers to create custom page environments. But sometimes there's a need for more flexibility in fetching data from the Dataverse as the example in this blog explains. The author spoke about how to do it using Power Fx, invoking fetchXmls and CustomAPIs in an easier way to get complex data. This can be particularly useful if you are a developer handling web applications and require a hands-on approach to managing data fetched from the Dataverse.

The author first outlines the problem statement, where they had the necessity to call complex fetchXmls and CustomAPIs to fetch data. The author also stated that this method would also work for making API calls. Here, understanding FetchXML, a proprietary, XML-based language would be useful. Alongside, comprehending the use of CustomAPIs would be beneficial.

In the tutorial, the author also leveraged the PCFs (Power Apps Component Framework) inside Custom Pages to make web API calls. Hence, understanding PCF as well as web API calls would be beneficial if you intend to grasp the approach better. Since there are two ways outlined for fetching data, understanding how to work with JSON and dynamic output object would be crucial.

For detailed understanding and hands-on experience, some technical training and courses can be taken. Microsoft Learn offers a wide array of courses on Power Fx, fetchXml, web API calls and much more. You could also look up free resources or tutorials on tech platforms like GitHub, StackOverflow, or freeCodeCamp.

The author also highlighted usage of PCF to retrieve data on the basis of fetchXml. This 'fetch' operation is essentially used in databasing languages, including SQL. Hence, considerable knowledge in database management and operations can be helpful.

While following the code snippets and commands disseminated by the author, it’s vital to know about FetchXML Builder by Jonas Rapp as it got helpful applications in the topic covered by this blog post. It's a tool in XrmToolBox library for building, testing and executing fetchXml commands. Hence, it is advised to have hands-on experience before implementing the code in real-time.

Finally, understanding UI rendering and debug exceptions handling in coding would be useful in closing the loop. The author also showcased defining variables in codes, hence having a robust understanding of data-type conversions and defining syntax in coding would be beneficial.

To summarize, having knowledge about FetchXml, PCFs, WebAPIs, building queries, database management, JSON scripts handling, command syntax defining would be beneficial to understand the approach delivered by the author. Above all, it's always recommended to explore related Microsoft documentation and Microsoft Learn’s extensive repository to keep oneself updated.

In addition to Microsoft Learn, other popular platforms such as Coursera, Udemy and Pluralsight also offer extensive courses on related topics and more.

More links on about Call FetchXml Inside Custom Pages Without Flows – The PCF Way

Call FetchXml Inside Custom Pages Without Flows – The PCF ...
Nov 13, 2022 — The feature I'm relying on: the PCFs inside Custom Pages are able to make webAPI calls. In this blog I'll show two ways to get the data from a ...
Call FetchXml Inside Custom Pages Without Flows
Dec 2, 2022 — For this blog I'll talk only about fetching data, but my solution works also for calling CustomAPIs. Way 1: use a PCF to retrieve data based on ...
Custom Pages - Dianamics PCF Lady - WordPress.com
Mar 19, 2023 — One of the latest ones, was about drag&drop inside a Custom Page or a Canvas App. ... Call FetchXml Inside Custom Pages Without Flows – The PCF ...

Keywords

PCF, FetchXml, Custom Pages, Without Flows, SEO, Search Keywords, Call FetchXml, The PCF Way, Inside Custom Pages, Custom Pages SEO