Power Apps Portals – ‘Page Not Found’ goes missing

The Power Apps (D365) Portals has a standard ‘Page Not Found’ feature that displays a customisable page when the user navigates to a URL that does not exist.

Page Not Found Page

What do you do if your ‘Page Not Found’ page is not found? I recently encountered this problem in an environment where an incorrect URL was displaying the dreaded 502 Error rather than the ‘Page Not Found’ page.

Portal 502 Error

This is where the Portal Checker in the Power Apps Portal Admin Centre is your friend. Run the Portal Checker and examine the results for the following entries.

Page Not Found Site Marker Configuration

Home Site Marker Configuration

If either of these have a Warning against them, check the respective Site Marker to ensure it is pointing to the correct page. In my case the Home Site Marker had been incorrectly modified and was no longer pointing to the relevant Home page. Having made the adjustment my ‘Page Not Found’ was operational again and incorrect URLs were being sent to the right page.

Power Apps Portals – Login By Email

Power Apps Portals support multiple authentication methods. For external accounts, managed through Contact records in D365, the process of registration used to require the user to provide a separate Username and Email address. Although this is still the default scenario it is now possible to require the user to provide only their email address for sign-in.

To modify the registration process, change the Authentication/Registration/LocalLoginByEmail Site Setting from false to true. No more having the use some crafty JQuery to populate a (hidden) Username field with the content of an email address.

Business Process Flows and hidden dependencies

When trying to delete a Business Process Flow you may get conflicting messages about dependencies that need to be removed before the BPF can be removed.

For example, trying the delete the BPF through Power Apps I got the following message.


When I tried to view the dependencies for the BPF it would show zero dependencies


The problem is that the BPF also creates a entity with the same name and we have to determine which dependencies are still linked to this entity. Details for completing this task can be found here – https://support.microsoft.com/en-in/help/4527365/business-process-flow-deletion-fails-due-to-an-unknown-dependency.

D365 Portals – application/xml

I keep forgetting how to do this and can’t remember where I saw it written down so I am writing this down now. If you need to check the fetchXML that is being called as part of a Web Template then you can return that fetchXML in a Web Page. This can be useful where you have fetchXML that is generated dynamically based on request parameters or if you just want to check the values that are included in your fetchXML from the request.params collection.

  1. Create the Web Template with your fetchXML query
  2. After the {% endfetchxml %} line, display the content of you fetchXML query using the XML property of your fetchXML object.
  3. Set the MIME Type of the Web Template to application/json
  4. Create a Page Template for your Web Template, with no headers or footers.
  5. Create a Page using the Page Template so you can get the XML content

For example, my Web Template would look like this

{% fetchxml assetQuery %}
<fetch version='1.0' output-format='xml-platform' mapping='logical' page='1' count='200'>
  <entity name='msdyn_customerasset' >
    <attribute name='msdyn_customerassetid' />
    <attribute name='msdyn_account' />
    <attribute name='msdyn_parentasset' />
    <attribute name='msdyn_name' />
{% endfetchxml %}

{{ assetQuery.xml }}

XrmToolbox – Portal Records Mover – Folder Structures

Version 1.2019.10.9 of the Portal Records Mover tool in the XrmToolbox has introduced an excellent new feature – the ability to export the content as a folder structure and with the option to ZIP up the content.

Portal Records Mover

Previously, the configuration would be exported into a single XML file which made it difficult to identify what items were included in your export once you closed down XrmToolbox and filed away your configuration in source control. With the new version if you elect to Export as folder structure then not only do your exports get separated into different folders but the configuration records are created as separate files. The filename is the GUID of the configuration record.

Portal Records Mover

Portal Records Mover

The other advantage this creates is that you can now be more selective on the configuration you want to import into your target environment. The source file for your import can now be the entire root folder, individual folders or individual file (ZIP or XML).

Portal Records Mover

D365 Portals : X-Content-Type-Options Header

In an earlier post I provided a few of options for dealing with JavaScript code in your D365 portals. The second of those options was to modify the extension of the file that is attached to the Web File Note so it isn’t blocked as an attachment.

With a recent upgrade to the portal it appears that Microsoft have now closed the door on that particular option and for good (security) reasons. They have now added the X-Content-Type-Options header to the response with a setting of nosniff. This means that when the browser detects a difference between the file extension and the MIME type then the browser generates an error and the script is not loaded.

This means that in order to use custom JavaScript files in your D365 portals you are left with either option #1 or option #3 from my previous post, or use a CDN.

D365 – Field Service – Debugging Booking Rules

Booking Rules in D365 are generated as Web Resources (JavaScript) to show warning or error messages to the scheduler. The problem with debugging these web resources is that the files are loaded dynamically which makes them a little harder to debug. When you have complex or a large number of booking rules you have a few options to assist you with debugging.

  • console.log – this is the most basic option but allows you to write out values to the debug console of the browser. This can give you some information may not pinpoint the exact line were an issue is occurring.
  • debugger statement – this will cause your web resource to load into the dev tools of the browser and stop on the line where the statement exists. This at least allows you to continue on with debugging but you need to remember to remove it before you publish the resource into a production environment.
  • sourceURL comment – if you place the following comment at the end of your script file – after the closing curly brace – the file will then show in the sources tab.
//# sourceURL=filename.js

You can replace filename.js with any filename you like, e.g. BookingRules.js. When you browse your Sources in the Dev Tools you will find the file and be able to put in breakpoints as required. You will need to force the booking rules to run at least once for the file to be loaded. The other good point about this technique is that you don’t need to remove the comment for the file when its moved to a production environment.

This works for Chrome, Firefox and the new Chromium Edge browsers.