Options

SaveasPDF from Classic Client

johntaylormfcjohntaylormfc Member Posts: 22
edited 2009-03-09 in NAV Three Tier
I believe that is is not possible to use the Report.SaveAsPDF from the Classic Client.

Could someone please confirm if this is true.

I have created a web service and with this code and when ran from a website it is fine.

Ideally I would like to run this from my classic client.

If the above is true, would it be possible to call my webservice from the classic client to create the PDF version of the report.

This would allow me to email the PDF from classic client, but it would use the nicer formatting of a RTC report.

Any suggsetions?

Thanks

John

Comments

  • Options
    gvolkovgvolkov Member Posts: 196
    Look into PDF creator on sourceforge.net

    You can use the Automation provided by PDF creator to save reports into PDF. I wrote numerous solutions using this software.

    I even posted some code here in Tips and Tricks that you can use to generate a pdf file.
    Microsoft Certified Technology Specialist
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified Business Management Solutions Specialist

    http://www.navisiontech.com
  • Options
    kinekine Member Posts: 12,562
    I believe that is is not possible to use the Report.SaveAsPDF from the Classic Client.

    Could someone please confirm if this is true.

    I have created a web service and with this code and when ran from a website it is fine.

    Ideally I would like to run this from my classic client.

    If the above is true, would it be possible to call my webservice from the classic client to create the PDF version of the report.

    This would allow me to email the PDF from classic client, but it would use the nicer formatting of a RTC report.

    Any suggsetions?

    Thanks

    John

    It's true, you cannot use it in Classic client. But of course, you can call the WebService from within NAV classic client.
    See e.g. http://mibuso.com/blogs/ara3n/2009/01/2 ... companies/
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    ara3nara3n Member Posts: 9,255
    Suddenly this web service solution is the answer to every question? :mrgreen:
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    johntaylormfcjohntaylormfc Member Posts: 22
    kine wrote:
    It's true, you cannot use it in Classic client. But of course, you can call the WebService from within NAV classic client.
    See e.g. http://mibuso.com/blogs/ara3n/2009/01/2 ... companies/

    This is what I am after. People will be emailing orders from a website or from within NAV. This should let them both call the same service, shich runs the same report, formatted in Visual Studio.

    Will look better and only one report to manage.

    Will try tomorrow and let you know how I get on.

    Thanks

    john
  • Options
    kinekine Member Posts: 12,562
    ara3n wrote:
    Suddenly this web service solution is the answer to every question? :mrgreen:

    Yes, mainly if it is clever, evident and easy solution like this... +good blog article...

    evident + easy + good blog = bestseller :mrgreen:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    garakgarak Member Posts: 3,263
    ara3n wrote:
    Suddenly this web service solution is the answer to every question? :mrgreen:

    not for all, but for some. It's easy and clever. Good example =D>
    Do you make it right, it works too!
  • Options
    ara3nara3n Member Posts: 9,255
    garak wrote:
    ara3n wrote:
    Suddenly this web service solution is the answer to every question? :mrgreen:

    not for all, but for some. It's easy and clever. Good example =D>

    Thanks. I will post some more ideas with this solution. Just have to get the time from somewhere.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    ara3n wrote:
    Suddenly this web service solution is the answer to every question? :mrgreen:


    yeah but if you don't put this stuff in the downloads section how are we supposed to vote for it. \:D/
    David Singleton
  • Options
    johntaylormfcjohntaylormfc Member Posts: 22
    I have had a look at this code and believe I understand what it is doing.

    I have changed it and pointed to my web service, but get an error

    “Http Error 401 : Unauthorised”

    I have tried running it from the a client on the server, windows authentication, logged in as Administrator. Also have tried changig the web service to run as Administrator, but still getting this error.

    As you probably can tell I dont know much about permissions etc.

    Any suggestions.

    Thanks again.

    John
  • Options
    johntaylormfcjohntaylormfc Member Posts: 22
    Have made a change

    added user and password to this line


    XmlHttp.open('POST','http://figaro:7047/DynamicsNAV/WS/CRONUS/Codeunit/WebFunctions',0, 'user',
    'Password');

    Now get Http Error 500: Internal Server Error

    It is now saying That my function name TK_CreatePOPDF is invalid. Still digging

    Possibly Progress
  • Options
    johntaylormfcjohntaylormfc Member Posts: 22
    Well I can now admit to being an idiot.

    I had a codeunit 50000 already, so imported the fob which had overwritten my CU, renumbered it and then reimported mine.

    I have ony just noticed that the renumber changed my web service to point the new number if the imported CU, not my original one.

    Now works a treat,

    Thanks

    john
  • Options
    johntaylormfcjohntaylormfc Member Posts: 22
    edited 2009-01-30
    In case anyone is Interested the code was as follows

    CU 50000 called web services has a function



    TK_CreatePOPDF(PONo : Code[20]) : Text[1000]
    PH.INIT;
    PH.RESET;
    PH.SETRANGE("No.", PONo);

    filename := 'C:\temp\';
    filename += FORMAT(CREATEGUID);
    filename := DELCHR(filename, '=', '{-}');
    filename += '.pdf';
    REPORT.SAVEASPDF(10576, filename, PH);

    EXIT(filename);




    The Publish this CU as a web Service called "WebFunctions"


    The add a function to the Purchase Header


    CreatePDF()
    IF ISCLEAR(XmlDoc) THEN
    CREATE(XmlDoc);
    IF ISCLEAR(XmlHttp) THEN
    CREATE(XmlHttp);

    XmlHttp.open('POST','http://figaro:7047/DynamicsNAV/WS/CRONUS/Codeunit/WebFunctions',0, 'username',
    'password');
    XmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
    XmlHttp.setRequestHeader('SOAPAction','TK_CreatePOPDF');

    XmlHttp.setTimeouts(10000,10000,10000,0); //change last parameter to zero to wait till webservice finishes the job

    XmlHttp.send('<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
    '<soap:Body><TK_CreatePOPDF xmlns="urn:microsoft-dynamics-schemas/codeunit/WebFunctions">' +
    '<pONo>'+"No."+'</pONo>'+
    '</TK_CreatePOPDF></soap:Body></soap:Envelope>');




    IF XmlHttp.status <> 200 THEN
    MESSAGE('Http Error ' + ' ' + FORMAT(XmlHttp.status) + ': ' + XmlHttp.statusText);

    XmlDoc.async := FALSE;
    XmlDoc.load(XmlHttp.responseBody);

    XmlNode := XmlDoc.selectSingleNode('//Soap:Envelope/Soap:Body/TK_CreatePOPDF_Result/return_value/');

    IF NOT ISCLEAR(XmlNode) THEN BEGIN
    MESSAGE('PDF created on server in '+XmlNode.text);
    END ELSE BEGIN
    XmlDoc.save('C:\temp\response.xml');
    HYPERLINK('C:\temp\response.xml');
    ERROR(Text50002);
    END;

    CLEAR(XmlDoc);
    CLEAR(XmlHttp)





    Now NAV can call "Purchase Header".CreatePDF

    The web site where some users enter PO's can call WebFunctions.TK_CreatePOPDF

    I now will update this to email the PDF


    Thanks for all the help
  • Options
    ara3nara3n Member Posts: 9,255
    ara3n wrote:
    Suddenly this web service solution is the answer to every question? :mrgreen:


    yeah but if you don't put this stuff in the downloads section how are we supposed to vote for it. \:D/


    :-k alIright I'll submit this one.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    ara3nara3n Member Posts: 9,255
    Well I can now admit to being an idiot.

    I had a codeunit 50000 already, so imported the fob which had overwritten my CU, renumbered it and then reimported mine.

    I have ony just noticed that the renumber changed my web service to point the new number if the imported CU, not my original one.

    Now works a treat,

    Thanks

    john

    I believe I attached as a text file so that users can change it to what ever object they want it to.
    Thanks for the feedback. I'm sure other people will use this solution.
    It sort of promotes people to upgrade to 2009. :)
    You are welcome.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    ara3nara3n Member Posts: 9,255
    here it is in the download section

    viewtopic.php?t=31544
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    sdeoresdeore Member Posts: 9
    Hi Rashed,

    Thank you very much for the solution.
    I have tried to implement the same but receiving an error as follows
    "either the caller does not have the required permission for the specified path is read-only".

    I am runing on the server with classic client and as an administrator with windows login.
    With the same login I am able to acess the same folder and have full control in security.

    Please let me know if you or anyone can help me on the same.

    Cheers --
    Swapnil
  • Options
    ara3nara3n Member Posts: 9,255
    Is the service tier and web service running as administrators?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.