Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Printing Form

Posted on by 4,818

Hi expert, if the shipping state is left blank, and when the user prints the sales order form, is there any way to prevent the printing (pops up error message (I know this) and then stop printing (not sure how)) till the user fills out the state. I understand it needs to add the trigger to the page, but if we do it from the report, is it possible and how? Thank you!

*This post is locked for comments

  • snoppy Profile Picture
    snoppy 4,818 on at
    RE: Printing Form

    Sorry to reply late! Yes it is working now after adding the code to aftergetRecord(). Thank you experts!

  • TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Printing Form

    Did you able to resolve this?

  • Alex Chow Profile Picture
    Alex Chow 4,481 on at
    RE: Printing Form

    Instead of writing the IF statement, you can accomplish the same thing with less typing:

    TESTFIELD("Ship-to County");

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Printing Form

    It works perfectly in my report.

    Put following code in the OnAfterGetRecord() trigger in your report Sales Header dataitem

  • snoppy Profile Picture
    snoppy 4,818 on at
    RE: Printing Form

    Hi expert, I tried, but it doesn't work.

    I am using the following code:

    IF "Sales Header"."Ship-to County"='' THEN

    "Sales Header".TESTFIELD("Ship-to County");

    Even though the user puts the value in the ship to county, the system still pops  up the error and it blocks the printing.

  • Suggested answer
    Saurabh Shah Profile Picture
    Saurabh Shah 4,560 on at
    RE: Printing Form

    Hi,

    I recommend to use the TESTFIELD(Field Name)  function in OnPreReport() in report to check that field must have some value so if it is blank then it will give error before printing.

    -Saurabh Shah

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Printing Form

    Hey,

    If you want to stop printing the report use following code in the Sales Header Dataitem in the report, onAfterGetRecord trigger

    IF ShippingStatus ='' THEN

       ERROR ('Shipping status should not be blank');

    This will stop printing the report and if you have several orders this will halt them too, even if other orders have the shipping status.  

    If you want to just skip the records that  does not meet your requirement then use following code in the Sales header Dataitem in the report, onAfterGetRecord trigger.

    IF ShippingStatus ='' THEN

      CurrReport.SKIP;

    Or else you can set the filters to your dataitems in their property.

    In the properties of the dataitem set the DataItemTableView to filter not empty values for the ShippingStatus.

  • Suggested answer
    jcastro Profile Picture
    jcastro 2,245 on at
    RE: Printing Form

    Hello Snoppy,

    If you wish to disable the user from printing the report from within the report, you can do it in several different ways.

    If you wish to stop the printing completely, you could go to the Sales Header dataitem in the report, onaftergetrecord trigger and add a condition such as: IF (ShippingStateField='') THEN ERROR('The shipping state must have a value') (or use a TESTFIELD sentence).

    If you do not want to stop the printing because the possibility of printing several sales orders is real and you do not want to stop the printing completely just because one record does not meet the requirement, you could use the CurrReport.SKIP function like this: IF (ShippingStateField='') THEN CurrReport.SKIP in the same trigger.

    http://msdn.microsoft.com/en-us/library/dd339042.aspx

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans