Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

AL: Validate Sales Header fields before PDF creation

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

  • Suggested answer
    NAV_with_Narang Profile Picture
    NAV_with_Narang 2,236 Super User 2024 Season 1 on at
    RE: AL: Validate Sales Header fields before PDF creation

    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

  • fvl92 Profile Picture
    fvl92 40 on at
    RE: AL: Validate Sales Header fields before PDF creation

    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
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: AL: Validate Sales Header fields before PDF creation

    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
    fvl92 40 on at
    RE: AL: Validate Sales Header fields before PDF creation

    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
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: AL: Validate Sales Header fields before PDF creation

    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
    fvl92 40 on at
    RE: AL: Validate Sales Header fields before PDF creation

    Hello Aman

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

    Thanks!

  • Suggested answer
    Dynamics 365 Profile Picture
    Dynamics 365 2 on at
    RE: AL: Validate Sales Header fields before PDF creation

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans