Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help - setting the file name for "Print Report as PDF File" action

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help - setting the file name for "Print Report as PDF File" action

    I am having a dumb. How do you change the name of a generated report PDF? I want to name my report something smart, like, "YOUR_USEFULLY_NAMED_REPORT.pdf". Not "CRYPTIC_309230923098342089.pdf".

    I've searched through the forum sort of fruitlessly over the last few days on this topic. I'm pretty sure I've seen the answer several times but it just didn't register.

    Here's my process for generating the report:

    1. Click on Button on Grid.
    2. OnClick event > Fire "Print Report as PDF File"
    3. Hello PDF file.

    In my "Report Print Genie", my Layout name is : REPORTNAME@some.alb. I am hazarding a guess here that is not the file name.

    I looked in PDF options for "Report Print Genie". I don't see anything here for "PDF file name"...

    Thanks to all who look! Extra thanks to those who respond!
    ---
    Sarah
    Alpha Anywhere latest pre-release

  • #2
    Re: Help - setting the file name for "Print Report as PDF File" action

    Sarah,
    At the risk of sounding stupid, why does it matter what the report is named?
    The user can save the file with any name desired from the browser, and you can save the file to the server, with a specific name, and then email it to the user.
    What am I missing?
    Jay
    Jay Talbott
    Lexington, KY

    Comment


    • #3
      Re: Help - setting the file name for "Print Report as PDF File" action

      Originally posted by Jay Talbott View Post
      Sarah,
      At the risk of sounding stupid, why does it matter what the report is named?
      The user can save the file with any name desired from the browser, and you can save the file to the server, with a specific name, and then email it to the user.
      What am I missing?
      Jay
      Not a stupid question!

      Short answer:
      Usability, presentation, & pride.

      Long answer:
      Half of this is personal; me wanting to not only deliver a solution, but a solution that is all buttoned up & shiny with minimal user involvement (requiring the user to rename the file to something useful falls in my "user involvement" bucket; not good.)

      The other half knows exactly what question/request will appear in my email the day I push it up to the testing server and send the link to my boss...

      Alpha's generated filename so cryptic and useless that every user will need to rename the document on save just so they know what they saved:

      MPL_090113182333184.pdf

      ...Seriously? In what parallel universe is that file name useful?

      I know what I want to name these files. I know what will be useful for the user. I want the file name to be useful without any extra work required by the user. If the user still doesn't like the generated informational file name, they can change it.

      But MPL_090113182333184.pdf?

      Inconceivable!

      SO I plow forward.

      In other news, I have discovered... JAVASCRIPT! In that the action that I setup can be converted to the raw javascript.

      That's when I found this!

      Code:
      	var ro = new Object();
      	ro.hostComponentType = 'Grid';
      	ro.reportName = 'MPL@afhp_sql.alb';
      	ro.reportNameShort = 'MPL';
      	ro.reportType = 'Report';
      	ro.reportIFrame = window['{Grid.ComponentName}_ACTIONBUTTON_PRINT_1'].getWindowId('body');;
      	ro.gridId = '{grid.componentName}';
      	[B][COLOR="#FF0000"]ro.download = 'N';[/COLOR][/B]
      	ro.xbasicFunction = '';
      	[B][COLOR="#FF0000"]ro.clientSideFilename = '';[/COLOR][/B]
      	ro.reportMessagesDivId = '';
      	ro.filter = '';
      	ro.order = '';
      	ro.sqlFilter = '';
      	ro.sqlOrder = '';
      	ro.arguments = 'DESIGN_ID|Numeric|'+{grid.object}._getValue('G','DESIGN_ID',rowNum)+'';
      	ro.workingMessage = 'Printing report: ' + ro.reportNameShort;
      	ro.pdfoptions = 'DIM Concatenate as L\nDIM HasWatermark as L\nDIM MultilingualSupport as L\nDIM EmbedFonts as L\nDIM LinearizeForWeb as L\nDIM Colors2GrayScale as L\nDIM ConvertHyperlinks as L\nDIM WatermarkType as C = `Text`\nDIM WatermarkText as C = `D R A F T`\nDIM WatermarkFontName as C = `Times New Roman`\nDIM WatermarkFontSize as N = 172\nDIM WatermarkRotation as N = 450\nDIM WatermarkColorHex as C = `E8FED2`\nDIM WatermarkHorizPos as N = 120\nDIM WatermarkVertPos as N = -120\nDIM WatermarkOnTop as L\nDIM WatermarkPDF as C\nDIM Encrypt as L\nDIM OwnerPassword as C\nDIM UserPassword as C\nDIM CanPrint as L = .T.\nDIM CanModifyDocument as L = .T.\nDIM CanCopy as L = .T.\nDIM CanAddNotes as L = .T.\nDIM Use128BitKey as L = .T.\nDIM JpegQuality as C = `Low`\n';
      	ro.displayMode = '';
      	ro.saveAs = 'pdf';
      	ro.pdfOpenParameters = ''
      	ro._gridCurrentFilter = {grid.object}._gridFilter;
      	ro._gridCurrentOrder = {grid.object}._gridOrder;
      	ro._gridCurrentArguments = {grid.object}._gridArguments;
      	ro._gridCurrentDBType = {grid.object}._gridDBType;
      	
      	ro.htmlReporting = false;
      AND THIS!

      http://msgboard.alphasoftware.com/al...ntSideFilename

      So. I think I found my solution. A better solution in my mind, actually.

      You see, generating a report to display it on the website is slow. And the separate act of having to save the generated PDF is equally slow. And I am reasonably confident that most people are going to save the PDF. So, I've decided to cut out the middle man and just download the PDF directly the the client's system. From there, they can decide what they want to do: open, save.

      Note, setting ro.clientSideFilename = 'anythingButEmpty.pdf'; resulted in a crash. "Error! Can't find that cryptic, useless file that A5 generates!" I found that I had to also change the download property to read ro.download = 'Y'. And comment out some other code.

      Hope I clarified your question!

      So, now I have a question for you:

      The user can save the file with any name desired from the browser, and you can save the file to the server, with a specific name, and then email it to the user.
      I am not well versed in the ways of reports. Or emails. But I know how to save files. How would I do that second one?!

      I must away now. I smell bacon!
      ---
      Sarah
      Alpha Anywhere latest pre-release

      Comment


      • #4
        Re: Help - setting the file name for "Print Report as PDF File" action

        Sarah, I've seen other posts from you and I know you are a JavaScript guru, so I hate to suggest this, but the old fashioned way for those of us who struggle with JavaScript is to do it in Xbasic. For example, I have a button on a grid that does a callback to create an invoice, name it with the invoice number and client name, stores it in a project and an Invoices direcotry. Yeah, it takes a while, but accounting likes it. The whole code is 160 lines, but a stripped down version without error checking is

        function printInvoice as c (e as p)
        ' save the invoice in the project directory
        vProjectName = e._currentRowDataNew.PROJECT_FULL_NAME
        vClientName = word(vProjectName,3,"_")
        vInvoiceNumber = e._currentRowDataNew.INVOICE_NUMBER
        vWhichInvoice = e._currentRowDataNew.INV_STATUS
        if vWhichInvoice = "DA"
        vWhich = blah blah
        else
        vWhich = "Other"
        end if
        if vWhich = blah blah
        ' stuff to update a history
        end if
        vZBDirectory = "C:\enefen\000_NFN_Projects"+chr(92)+vProjectName+"\NFNFinished"
        vEADirectory = "C:\000_NFN_QBBackup\NFN_Invoices\Invoices_2012"

        ' make sure the ZB directory exists
        vResult=dir_create_recurse(vDirectory)
        sleep(.5)

        ' this is the part that names the invoice
        vFilename = "Invoice_"+vInvoiceNumber+"_"+vClientName+"_"+date_format(date(),"yyyyMMdd")+"_"+time("0h0m")+".pdf"
        vSource = session.session_folder + chr(92) + vFilename
        vZBDestination = vZBDirectory + chr(92) + vFilename
        vEADestination = vEADirectory + chr(92) + vFilename
        dim opts as p
        opts.filter = "INVOICE_NUMBER = "+vInvoiceNumber
        opts.order = ""
        dim vReport as c
        vReport = report.saveas("invoice@c:\nfn_v11\nfn.alb","pdf","","",vSource,.f.,NULL,NULL_VALUE(),opts)
        sleep(2)
        ' if that worked, save the pdf in the project directory and the accounting directory
        if file.exists(vReport)
        file.copy(vSource,vZBDestination)
        ' file.copy(vSource,vJ_Drive)
        file.copy(vSource,vEADestination)
        ' open the pdf
        response.redirect(vSource)
        end if
        PrintErrorOut:
        'end
        end function
        Pat Bremkamp
        MindKicks Consulting

        Comment


        • #5
          Re: Help - setting the file name for "Print Report as PDF File" action

          Originally posted by Pat Bremkamp View Post
          Sarah, I've seen other posts from you and I know you are a JavaScript guru, so I hate to suggest this, but the old fashioned way for those of us who struggle with JavaScript is to do it in Xbasic. For example, I have a button on a grid that does a callback to create an invoice, name it with the invoice number and client name, stores it in a project and an Invoices direcotry. Yeah, it takes a while, but accounting likes it. The whole code is 160 lines, but a stripped down version without error checking is

          function printInvoice as c (e as p)
          ' save the invoice in the project directory
          vProjectName = e._currentRowDataNew.PROJECT_FULL_NAME
          vClientName = word(vProjectName,3,"_")
          vInvoiceNumber = e._currentRowDataNew.INVOICE_NUMBER
          vWhichInvoice = e._currentRowDataNew.INV_STATUS
          if vWhichInvoice = "DA"
          vWhich = blah blah
          else
          vWhich = "Other"
          end if
          if vWhich = blah blah
          ' stuff to update a history
          end if
          vZBDirectory = "C:\enefen\000_NFN_Projects"+chr(92)+vProjectName+"\NFNFinished"
          vEADirectory = "C:\000_NFN_QBBackup\NFN_Invoices\Invoices_2012"

          ' make sure the ZB directory exists
          vResult=dir_create_recurse(vDirectory)
          sleep(.5)

          ' this is the part that names the invoice
          vFilename = "Invoice_"+vInvoiceNumber+"_"+vClientName+"_"+date_format(date(),"yyyyMMdd")+"_"+time("0h0m")+".pdf"
          vSource = session.session_folder + chr(92) + vFilename
          vZBDestination = vZBDirectory + chr(92) + vFilename
          vEADestination = vEADirectory + chr(92) + vFilename
          dim opts as p
          opts.filter = "INVOICE_NUMBER = "+vInvoiceNumber
          opts.order = ""
          dim vReport as c
          vReport = report.saveas("invoice@c:\nfn_v11\nfn.alb","pdf","","",vSource,.f.,NULL,NULL_VALUE(),opts)
          sleep(2)
          ' if that worked, save the pdf in the project directory and the accounting directory
          if file.exists(vReport)
          file.copy(vSource,vZBDestination)
          ' file.copy(vSource,vJ_Drive)
          file.copy(vSource,vEADestination)
          ' open the pdf
          response.redirect(vSource)
          end if
          PrintErrorOut:
          'end
          end function
          Ah! Yes! Fabulous! This is all starting to make more sense. Thank you very much!

          I'm pretty 100% sure the PDF generating code is done server side and then either downloaded to the client computer or saved in the session folder and then downloaded to the client computer. If I can do it server side, all the better! I gotta start making all these reports and put them all over the place. Server. Client. I need to do both.

          I think I'm on the opposite side of the spectrum here on xbasic. I look at it and go cross-eyed trying to determine whether or not a function exists in the alpha library that does what I need. The other day I needed a "find_last_of" function. Alpha named their equivalent RAT. RAT? Reverse... at?

          I question the naming conventions of these functions... always.
          ---
          Sarah
          Alpha Anywhere latest pre-release

          Comment


          • #6
            Re: Help - setting the file name for "Print Report as PDF File" action

            One more question >>> I am so close to being done with this thing...

            How would I detect if the generated report is... blank? I noticed the file size is, like, 3 KB. Is there a way to get more information out of the saveas function that will tell me if the report is blank?

            ---
            Sarah
            Alpha Anywhere latest pre-release

            Comment


            • #7
              Re: Help - setting the file name for "Print Report as PDF File" action

              Answered my own question -- I just test my data to see if conditions hold for the report to generate anything.

              I found a5_default_path to help me with my report.saveas business --- separate testing & live servers. And also my local machine here. Too many headaches to change this constantly:

              Code:
              dim albLoc as c
              albLoc = a5_removetrailingbackslash(a5_default_path) + chr(92) + "my.alb"
              results = report.saveas("MYREPORT@" + albLoc, etc, etc, etc...)
              In reading other threads, I figured out that looking inside the published __a5RunReport.a5w file is actually super duper helpful in figuring out all this stuff.

              AND! I added some code to show a "wait, you people" message. It's not special. I'm pretty sure everyone does it like this:
              Code:
              A5.msgBox.show('Creating PDF',
                             '<div style=\'width:200px;padding:10px;vertical-align:middle;\'><img src=\'CSS/A5System/Images/wait.gif\'/>Creating PDF. Please Wait.<br\>The PDF will be displayed once the operation completes.</div>',
                             'none',
                             function() {});
              $('A5dlg0.TITLE.TOOLS.close').style.display = 'none';
              But I got it to hide the popup window's close button! I'm making a huge assumption here that the popup's ID will never change. I may have just created a landmine for myself later.

              Onward! With more explosions!
              ---
              Sarah
              Alpha Anywhere latest pre-release

              Comment


              • #8
                Re: Help - setting the file name for &quot;Print Report as PDF File&quot; action

                Anyone figure this out yet? Tired of having goofy file names. Would like to custom name and time stamp them.

                Comment


                • #9
                  Re: Help - setting the file name for &quot;Print Report as PDF File&quot; action

                  Originally posted by neilbob View Post
                  Anyone figure this out yet? Tired of having goofy file names. Would like to custom name and time stamp them.
                  Neil - read Pat's reply (reply #4.) It's xbasic and includes naming the file.

                  Code:
                  ' this is the part that names the invoice
                  vFilename = "Invoice_"+vInvoiceNumber+"_"+vClientName+"_"+date_format(date(),"yyyyMMdd")+"_"+time("0h0m")+".pdf"
                  vSource = session.session_folder + chr(92) + vFilename
                  vZBDestination = vZBDirectory + chr(92) + vFilename
                  vEADestination = vEADirectory + chr(92) + vFilename
                  Also, session.session_folder is deprecated, so you need to use the suggested methods listed here (they work way better IMO): http://wiki.alphasoftware.com/~alpha...n+Sessions+V11
                  Alpha Anywhere latest pre-release

                  Comment

                  Working...
                  X