Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

NAV 2013 R2. Select printer for report from code

Posted on by 2,983

Is there a way to select the destination printer of a report programatically when calling a report run?

In this case user and report Id are not enough, the destination printer is chosen depending on other criteria like customer No. and country, so we need to choose the printer from code.

*This post is locked for comments

  • jaloag Profile Picture
    jaloag 674 on at
    RE: NAV 2013 R2. Select printer for report from code

    Great Ghetz! Thanks for share it.

  • jcastro Profile Picture
    jcastro 2,245 on at
    RE: NAV 2013 R2. Select printer for report from code

    Thank you for sharing this! I didn't know they added this function. It looks interesting. I'll make sure to check it out.

  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: NAV 2013 R2. Select printer for report from code

    Thanks guys! Interesting solutions all three. I have to check with my team what approach we shall use.

    Just let me comment, for NAV 2015 there seems to be a standard solution. We have the REPORT.PRINT function, that takes the PrinterName parameter:

    REPORT.PRINT(Number, Parameters[,PrinterName][, RecordRef])


    It would be nice to have this for NAV 2013 R2 :(

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: NAV 2013 R2. Select printer for report from code

    Hi

    The way I've done this in the past is to have two copies of the same report, say 50000 and 50001.  Then use standard NAV Printer selections to define which printer is used and modified NAV to chose the correct report based on your criteria.

    Small downside is that you use two report objects but that normally is not a big issue.  Also, you have to remember to copy any changes (or actually just the whole report) made to one report to the other.

    Hope this helps!

    Cheers

    Chris

  • Suggested answer
    jcastro Profile Picture
    jcastro 2,245 on at
    RE: NAV 2013 R2. Select printer for report from code

    The way that I can think of is basically changing the printer in the "Printer Selection" table before the report is run for that user and report id. That could work. It's not elegant but I think it's easier.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: NAV 2013 R2. Select printer for report from code

    One possible solution i can think of is to change the default printer programmatically using powershell and excecute that powershell script in the NAV Code.

    How to change default printer

    https://technet.microsoft.com/en-us/library/ff731009.aspx

    How to execute Powershell from NAV

    http://www.waldo.be/2014/12/17/running-powershell-from-nav/

    If you don't want to use powershell i think you can also use windows script or .net

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans