Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Print a Report

Posted on by Microsoft Employee

I'm trying to setup an action button to print a label. I've created the button on the page actions, declared a variable with my report name and used this code under the action button 


recBinContents.RESET;
recBinContents.SETRANGE("Item No.", "Item No.");
rptLewistest.SETTABLEVIEW(recBinContents);
rptLewistest.RUN;

However when I attempt to open the page which should allow me to preview the report nothing is loading? 

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Print a Report

    thank you i've done some moving about and managed to get a working report. I'm now trying to add the Item Ledger dataset so I can populate the LotNo and other things onto my report. If it's relating to the item page what would my DataTableView be and my Dataitemlink?

  • Andrea Antoniazzi Profile Picture
    Andrea Antoniazzi 285 on at
    RE: Print a Report

    Hi Lewishhh,

    I think the report is processing all the Item Ledger Entries; this is the reason why you receive so much lines.

    If you don't need the Item Ledger Entry DataItem, you have to remove it.

    In the DataItemTableView remove WHERE(Item No.=CONST())

    Best regards

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Print a Report

    H Thank you, I'm still very unsure what's casuing the report to not load.

    Here is my Code on the Button to show the report..

    recBinContents.RESET;

    recBinContents.SETCURRENTKEY("Item No.");

    recBinContents.SETRANGE("Item No.","Item No.");

    IF recBinContents.FINDFIRST THEN BEGIN

     rptLewistest.SETTABLEVIEW(recBinContents);

     rptLewistest.RUN;

    END;

    here is the Datasets, Both Bin Contents and Item ledger are required. 

    88.PNG

    Here's the properties for The Bin Contents Data Item, I think maybe the DataItemTableView is wrong? 

    88.PNG

    Feedback is greatly appreciated! :)

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Print a Report

    Check on the dataset and filter it for only the necessary record. Plus try changing to RUN without RUNMODEL. When you have the RUNMODEL application wait till the report process over.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Print a Report

    Thank you, The reports button's working now, however when you select preview and enter the No of labels etc it get stuck, attempting to load thousands of rows.86.PNG

    Do you know what the potential cause for this is? 

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Print a Report

    Hi,

    Kindly debug and check whether you are getting the record to display for the report

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Print a Report

    Try running below code,

    recBinContents.RESET;
    recBinContents.SETCURRENTKEY("Item No.");
    recBinContents.SETRANGE("Item No.", "Item No.");
    IF recBinContents.FINDFIRST THEN BEGIN
    REPORT.RUNMODAL(RepNo,recBinContents); // add your report no
    END;


    If the code is not working then debug the code and you will be able to find the issue in it.

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Print a Report

    Debug that code and check it find records or not, if find then definitely report will run.

    But also check report which you want to execute, report request page, and layout, first run from development environment/custom Report Layout

    Note, Report must have recBinContents dataitem

    See this image its tested.

    reportmodal.png

  • Andrea Antoniazzi Profile Picture
    Andrea Antoniazzi 285 on at
    RE: Print a Report

    Hi Lewishhh,

    try with recBinContents.SETFILTER("Item No.", "Item No.");

    Best regards.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Print a Report

    Hi Thankyou however when I click the button nothing appears to be happening.. As if the RUN function isn't working properly.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans