How to format date bound to Custom Xml Part

We are using Word document layouts for customer facing Business Central 365 (SaaS) reports. When binding a date to a Text Content Control, how do you format said date?

Answers

  • j2associatesj2associates Member Posts: 7
    What I have found so far is that it appears you have to do a Report Extension for a different date format. If you look at Report 1322 Purchase - Order you will see that all of the Date columns are defined as Format(DateField, 0, 4) which displays the full month names (e.g. September 15, 2019). This forces you to either have very wide date fields to accommodate long month names or have a lot of word wrap.

    I created a Report Extension for Report 1322 Purchase - Order with the following definitions:

    add("Purchase Line")
    {
    column(PlannedReceiptDate_Date; "Planned Receipt Date") { }
    column(PlannedReceiptDate_Formatted; Format("Planned Receipt Date", 0, '<Month,2>/<Day,2>/<Year4>')) { }
    }

    Using the Report Extension, I tried the following in a Word document layout:
    1. Added PlannedReceiptDate_Date to a detail line using a Date Picker Content Control
    a. The SaaS report generator ignores any formatting applied to the Content Control
    b. I had it formatted as MM/dd/yyyy and it displayed with that format but also displayed the time as midnight

    2. Added PlannedReceiptDate_Formatted to a detail line using a Plain Text Content Control
    a. This displayed as expected and desired

    It seems absurd to have to write a Report Extension to get a different date format, but perhaps that will change in the (near) future. Prior to Report Extensions, you had to create an entire report just to add one custom field to an existing report.
Sign In or Register to comment.