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

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Printing Form

(0) ShareShare
ReportReport
Posted on by 4,824

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

I have the same question (0)
  • Suggested answer
    jcastro Profile Picture
    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

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 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
    Saurabh Shah Profile Picture
    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

  • snoppy Profile Picture
    4,824 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
    Tharanga Chandrasekara Profile Picture
    23,118 on at
    RE: Printing Form

    It works perfectly in my report.

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

  • Alex Chow Profile Picture
    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");

  • Tharanga Chandrasekara Profile Picture
    23,118 on at
    RE: Printing Form

    Did you able to resolve this?

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

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

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans