BC is awash with Microsoft Teams touch points. My contribution to the sub topic is to furnish users with a card of financial data. This is a central way to distribute the information and provides an option outside of a regular report view. Here is an example of the end result:
Thankfully the standard BC API comes with an endpoint which is highly suitable – agedaccountsreceivable_get. There are a few others in the BC standard API list which fit the bill too: cashFlowStatement, agedAccountsPayable, trialBalance etc.
The handy thing about the agedAccountsReceivable endpoint is that it comes with a “Total” section π check out the example payload:
"value": [
{
"@odata.etag": "W/\"JzE5OzkxNDA2OTk1MDYwNDE0ODYxNzMxOzAwOyc=\"",
"customerId": "00000000-0000-0000-0000-000000000000",
"customerNumber": "",
"name": "Total",
"currencyCode": "",
"balanceDue": 44005.48,
"currentAmount": 0,
"period1Amount": 1236.6,
"period2Amount": 15109.44,
"period3Amount": 27659.44,
"agedAsOfDate": "2023-05-24",
"periodLengthFilter": "30D"
}
]
Things look decent. However, a minor drawback of the standard API is that it breaks the data up differently to the standard BC report you get in the UI
Microsoft kindly provide a few adaptive card templates. It was in fact this template which caught my eye and gave me the idea for this post: https://github.com/pnp/AdaptiveCards-Templates/tree/main/samples/payslip. If you’re new to the concept merely pick up a template and open up https://adaptivecards.io/designer/ and paste in the example json. I have a specific one for you to use if you want to achieve the same result as me. It is handy to use the designer to verify your final JSON object validates. There is of course a need for various pieces of text to be swapped out for dynamic values from BC data.
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"__comment": "Elements used",
"body": [
{
"type": "Container"
},
{
"type": "TextBlock",
"text": "Aged Debtors Report",
"wrap": true,
"horizontalAlignment": "Center",
"size": "ExtraLarge",
"fontType": "Default",
"weight": "Bolder"
},
{
"type": "TextBlock",
"text": "As of ",
"wrap": true,
"horizontalAlignment": "Center",
"size": "Medium",
"fontType": "Default"
},
{
"type": "Container",
"items": [
{
"type": "Image",
"url": "https://raw.githubusercontent.com/pnp/AdaptiveCards-Templates/main/samples/payslip/assets/img_spacer.png"
},
{
"type": "TextBlock",
"text": "By Ageing Band",
"wrap": true,
"weight": "Bolder",
"color": "Accent",
"size": "Large"
}
],
"spacing": "ExtraLarge"
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"wrap": true,
"weight": "Bolder"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "\n\n0 Days\n\n30 Days\n\n60 Days\n\n61+ Days",
"wrap": true,
"spacing": "Small",
"weight": "Bolder"
},
{
"type": "Container"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "\n\nΒ£\n\nΒ£\n\nΒ£\n\nΒ£",
"wrap": true,
"spacing": "Small",
"horizontalAlignment": "Right",
"weight": "Bolder"
}
]
}
]
}
],
"spacing": "Medium"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "\n\nTOTAL OUTSTANDING",
"wrap": true,
"weight": "Bolder",
"size": "Large",
"color": "Accent",
"spacing": "ExtraLarge"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "\n\nΒ£",
"wrap": true,
"weight": "Bolder",
"size": "Medium",
"color": "Accent",
"horizontalAlignment": "Right",
"spacing": "ExtraLarge"
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "π Open in System",
"url": "https://businesscentral.dynamics.com/<tenantID>/Sandbox?report=120"
}
]
}
]
}
],
"spacing": "ExtraLarge",
"separator": true
}
],
"backgroundImage": {
"horizontalAlignment": "Center"
}
}
The above has various sections missing so that you can copy/paste without any validation issues. If you set everything as I have it then grab the JSON template from my github. The below images show what I have added in and the formulas used. Only part which is not covered by an image is the OpenUrl action which requires a tenantID and the database name you want to access. These could be variables in the overall flow if you find that easier:
Want to have 1 extra ageing band bucket? Sadly the codeunit which runs this functionality doesn’t have the necessary aspects for us to alter it by events. Instead I elected to extend the table and copy the API page and codeunit. You can find the code on my github https://github.com/JAng13sea/Blogs/BCTeamsARCard