web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Create Expression in Microsoft Word

(0) ShareShare
ReportReport
Posted on by 35

Hello all!

Does anyone know of a way to build what is an 'expression' in report builder, but in Microsoft Word? 

I am creating custom forms in word layout and need to multiply three fields. 

If there is not a way to do this in word, does anyone know the VS code script that would help me to make a 'calculated column' that gets the product of all three fields?

Thanks!

Chrisg123

I have the same question (0)
  • Suggested answer
    Brad_P Profile Picture
    1,549 on at

    Hi,

    If you're using a table, you can try a formula - support.microsoft.com/.../use-a-formula-in-a-word-or-outlook-table-cbd0596e-ea8a-485e-a35d-b2cb2c4f3e27

    You'll most likely need to add it to the dataset, which you can do by adding a column that contains the product of the three fields, by definition or variable.

    For example, add a column to the report dataitem and then add a trigger to do "something" and assign it to a variable, that is the value used in the column,=.

    column(ProductofFields; ProductofFields)

    { }

               trigger OnAfterGetRecord()

               begin

                   ProductofFields := Dataitemname.Field1 * Dataitemname.Field2 * Dataitemname.Field3;

               end;

    // Add a global var

    var

      ProductofFields: Decimal;

  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at

    Hi, I suggest to calculate it in your Report Object and only display the result on Word Layout. It will save a lot of time when checking.

    Hope this helps.

    Thanks.

    ZHU

  • ChrisG123 Profile Picture
    35 on at

    Hi Zhu, thanks for your response.

    What do you mean by this? Can you provide screenshots?

    Thanks!

    Chris

  • ChrisG123 Profile Picture
    35 on at

    Hey Brad,

    Thanks for the response!

    While I put that in exactly, it seems like it is calculating, but not pulling in the right information?

    Here are some snippets of code to help solve this:

    (Calculation)

    pastedimage1668701030892v1.png

    (TableExtension putting fields into prod order line based on other table fields I couldn't pull in without)

    pastedimage1668701113961v2.png

    "HTC" is defined as a column in "Production order routing line" to be able to use a repeater/grouping in a word layout. It is also defined as a global variable. 

    Please let me know what you think. 

    Thanks a ton, 

    Chris

  • Suggested answer
    Brad_P Profile Picture
    1,549 on at

    Is the report a processing report to update the data or do you want to display it? If the value calculated is stored on a field, then you could include that field on the dataitem. If you're calculating it to show it on a report, you need to add the column with the variable to the appropriate dataitem  - column(HTC; HTC)

  • ChrisG123 Profile Picture
    35 on at

    Hi Brad, I am calculating it to show on a report. It currently isn't directly under the repeating section(rather the one above it), so I'll move the column there now.

    Do you have any resources for working with vs code and repeaters?

    Chris

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans