Scenario Overview

The customer's requirement in this article was to have a clickable link that would show the oldest unpaid Invoice on that Account.


N52 Formula Manager Solution


The formula manager solution works like this:
  • We create a formula of type ClientSide-Calculation on the Account
  • The formula will use Fetch-XML to find all the unpaid Invoices on that account in order of oldest due date
  • We select the first record found and create a hyperlink for it
  • If no records found we just return a message saying No Unpaid Invoices

Adding the Button to the Form

  • Open the Form editor
  • Select Insert -> Web Resource.
  • Choose the north52_quick_button_hyperlink.htm web resource
  • Add the Custom Parameters
    • The shortcode of the formula you want to use
    • (Optional) How many pixels from the left you want to move the text
If you have never used Quick Button before you can see more detailed documentation at this link.



  SetVar('All Invoices', FindRecordsFD('FindOldestInvoice','true')),

  SetVar('Oldest Invoice', FindRecordsValue(GetVar('All Invoices'), 'invoiceid', '?')),

  If(ContainsData(GetVar('Oldest Invoice')),

    LinkHyperLinkUrl('', 'invoice', GetVar('Oldest Invoice'), 'Oldest Unpaid Invoice'),

    'No Unpaid Invoices'


<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="invoice">
    <attribute name="totalamount" />
    <attribute name="invoiceid" />
    <attribute name="duedate" />
    <order attribute="duedate" descending="false" />
    <filter type="and">
      <condition attribute="customerid" operator="eq" value="@accountid@" />
      <condition attribute="statecode" operator="eq" value="0" />

Did you know?

Automated tests in Dynamics 365 helps with documenting processes

Maintaining automated tests helps you create 'living' documentation of your Dynamics 365 systems, minimising the potenetial for frustrating rework.

Building a test validates the requirements, makes it easy to spot ambiguity and incompleteness and can catch defects before they are released. 

As requirements change, tests need to be updated to ensure they continue to validate, thus ensuring the documentation stays up to date.

Learn how TestShield helps automate testing in Dynamics 365