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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

AL: Validate Sales Header fields before PDF creation

(0) ShareShare
ReportReport
Posted on by 40

Hey!

I am trying to validate if all necessary fields are entered before an PDF is created and attached.

How would I go on to do that?

thanks a lot and greetings

I have the same question (0)
  • Suggested answer
    Dynamics 365 Profile Picture
    6 on at

    Hello

    You have to make the field mandatory at Document Header level or Line level for those who were add at PDF.

    Please ask your developer to do so.

    Please Verify my answer if you found relevant so it will help to others member also.

    Thanks

  • fvl92 Profile Picture
    40 on at

    Hello Aman

    Thanks for you answer. I am looking to set this up, so I am more looking towards technical ideas

    Thanks!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,161 Moderator on at

    What do you mean by set this up?

    There is no setup that will allow you to configure this in the standard system.

    So what you will have to do is to customize a report that check if all necessary fields are there before it allows the report to be printed.

  • fvl92 Profile Picture
    40 on at

    Hello Inge,

    my mistake, english is not my first language.

    Exaclty!

    What I am trying to do: On Page-Extension Sales Quote I am trying to find a trigger on PDF creation that lets me perform Testfield on the different fields

    Thank you!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,161 Moderator on at

    Either you should add an action to your page extension and do you testfields in that action or you should the testfield as part of the report that create your code.

    To do it in a page trigger is not so smart in my eyes.

    If you use the release function before you create the pdf you could also subscribe to the OnBeforeRelease event.

    Personally i think the best way is to build the testfields into the report that is used for creating the PDF. In that way you make sure the testfields are executed no matter from where you start your report.

  • fvl92 Profile Picture
    40 on at

    Thank you for your answer Inge!

    Interesting, I see your reasoning as this being a general good approach.

    On a more specific note: What kind of scenarios could there be, where I would generate a Sales Quote outside of the Sales Quote PDF functions?

  • Suggested answer
    NAV_with_Narang Profile Picture
    2,320 Moderator on at

    Hi - I think you are combining two different things or I've misunderstood. But I'll try:

    1. If you want the PDF to not be printed from Sales Quote if certain fields are not having values, use the Report triggers to write your errors and not page triggers. You can use relevant table's OnAfterGetRecord as you'll get all values here straightaway

    2. You can alternatively make use of a Subscriber which will be called as soon as the PRINT button is pressed from the page. Once event named "OnBeforeActionEvent" is called via your subscriber, you can do TESTFIELD of various fields here in this snippet only. Only when there are no errors from these TESTFIELDS, will your report request page come up. Sample code screenshot below

    pastedimage1673015456907v1.png

    Do verify the answer by clicking "YES" for "Did this answer your question" - if you feel it helped you in anyway, so that others can get benefit out of it too. Thankyou very much for taking out time to read

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,821 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,122 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans