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

email rpt for current record when click submit

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

  • email rpt for current record when click submit

    Okay, I've searched the message board but I must not be entering the search term right. I can't seem to find anything that would give me a clue how to email the current record as a PDF, when the Submit button is clicked.

    The code I have kind of works, but I get the first record in the table, not the current one. I'm sure its my query filter but no matter what syntax I try, I either get an error and no report is generated, or I get the first record in the table attached to the email message in the report.

    Any help you all could provide would be GREATLY appreciated!

    I have a data entry page (a5w page) with the following code on the web component AfterUpdate section:

    function AfterUpdateRecords as v (Args as P, PageVariables as P)
    with PageVariables

    dim tbl as p
    dim cid as c
    dim session.__protected__user as c
    dim session.__protected__trx as c
    dim session.__protected__email as c


    tbl=table.open("[PathAlias.ADB_Path]\requests.dbf")
    Current_Record = tbl.recno()


    query.filter = "recno() =" + var->Current_Record
    query.order = ""

    filename = session.session_folder + chr(92) + "New_Element_Request.pdf"
    report.saveas("[email protected][PathAlias.ADB_Path]\requests.ddd","PDF", query.filter, query.order,filename, .f.)

    if file.exists(filename)
    response.redirect(session.session_url + "New_Element_Request.pdf?" + time("hms3"))
    end if

    DIM ps as P
    DIM pm as P

    e_attach = filename

    pm.from = "[email protected]"
    pm.from_alias = "New Element Request System"
    pm.to = "[email protected]"
    pm.subject = "New Element Request Added"
    pm.message = ""
    pm.attachments = e_attach
    'optional header fields
    pm.lRelated = .F.
    ' send message
    IF email_smtp_open(ps, "emailserver.domain.com" ,25 , "userid" , "******")
    email_smtp_send(pm, ps)
    END IF
    Email_smtp_close(ps)


    end with
    end function



    Thanks!!
    Land of the Free, Because of the Brave
    Support our US Military

  • #2
    Re: email rpt for current record when click submit

    It's because you are setting current_record to tbl.recno(), which will always return 1 if not indexed, or some other value if indexed, but always the first record in that index.

    The order of records in the Grid, or what is visible at any given time has NOTHING to do with organizing the table in to any order or restricting the records by a query.

    I would create a link to an A5W page with your code, include in the link the primary key, like mypage.a5w?id={id}, adjusted to fit your data.

    In the mhypage.a5w use the "id" as a page variable to create the filter for your report.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

    Comment


    • #3
      Re: email rpt for current record when click submit

      Thank you very much Steve. I will try that next.
      Land of the Free, Because of the Brave
      Support our US Military

      Comment


      • #4
        Re: email rpt for current record when click submit

        Hi,
        I'm back working on my problem program. . .

        The primary key for the table requests is req_id. I have changed my submit button to only redirect to the page with the code -- linkpage.a5w.

        response.redirect("LinkPage.a5w?id={Req_id}")

        I placed the code that runs the report and sends the email on the page linkpage.a5w . No email is sent or report generated because I get an error every time.

        Example error message:

        "Script Error
        Error:command: id={Req_Id}
        Constant operator is not recognized"

        or

        "Script Error
        Error:Script: /rne/LinkPage.a5w line:9
        DIM id as n
        Variable is of different type"

        I am doing something wrong because I get an error regarding the req_id. Can't figure it out, and of course they are bugging me to hurry with the program so they can roll it out.

        What I am trying to do shouldn't be this difficult -- They want a data entry form to add a new request to the db. When the user clicks submit, the data gets entered in the db (this works), an email is generated to the submitter and the approver, and a report showing what was entered is generated as a pdf and sent as an attachment to the email. The data is in one table.

        I am open to starting over on the data entry page, but really need some help in getting this to work. I know exactly how I would do this in the desktop version but the VP wants this application solely web based .
        Land of the Free, Because of the Brave
        Support our US Military

        Comment


        • #5
          Re: email rpt for current record when click submit

          I changed the linkpage.a5w code and now get the following error.


          500 Internal Server Error
          "Script Error
          Error:
          Amyuni Low Level Print:
          Layout name: [email protected][PathAlias.ADB_Path]\requests.ddd
          Layout type: report
          Invalid report filter expression: 'tbl.req_id =0'."


          Here is the code on the page:

          <html>
          <head>
          <meta name="generator" content="Alpha Five HTML Editor Version 9 Build 1634-3197">
          <title></title>
          </head>
          <body>
          <p>&nbsp;</p>
          <%a5
          DIM Req as N
          DIM Current_Record as N
          dim tbl as p
          dim cid as c
          dim session.__protected__user as c
          dim session.__protected__trx as c
          dim session.__protected__email as c

          Req = "{id}"
          'Current_Record = recno()

          tbl=table.open("[PathAlias.ADB_Path]\requests.dbf")

          query.filter = "tbl.req_id =" + var->Req
          query.order = ""

          filename = session.session_folder + chr(92) + "New_Element_Request.pdf"
          report.saveas("[email protected][PathAlias.ADB_Path]\requests.ddd","PDF", query.filter, query.order,filename, .f.)

          if file.exists(filename)

          'response.redirect(session.session_url + "New_Element_Request.pdf?" + time("hms3"))
          end if

          ' Now email the report
          DIM ps as P
          DIM pm as P

          e_attach = filename

          pm.from = "[email protected]"
          pm.from_alias = "New Element Request System"
          pm.to = "[email protected]"
          pm.subject = "New Element Request Added"
          pm.message = "Thank you for your submission. "
          pm.message = ""
          pm.attachments = e_attach
          'optional header fields
          pm.lRelated = .F.
          ' send message
          IF email_smtp_open(ps, "emailserver.domain.com" ,25 , "uid" , "pwd")
          email_smtp_send(pm, ps)
          END IF
          Email_smtp_close(ps)

          response.redirect(session.session_url + "New_Element_Request.pdf?" + time("hms3"))

          tbl.close()
          %>
          </body></html>



          If there is someone out there who knows what I'm doing wrong, please let me know. Somehow I've got to get this to work.
          Land of the Free, Because of the Brave
          Support our US Military

          Comment


          • #6
            Re: email rpt for current record when click submit

            Bummer, misread that!
            I think you need.....

            query.filter = "req_id =" + var->Req

            The report doesn't understand tbl.req_id since the report is already built on the table.
            Last edited by Stan Mathews; 08-19-2009, 02:53 PM.
            There can be only one.

            Comment


            • #7
              Re: email rpt for current record when click submit

              Ok I tried your suggestion. Still getting this error:

              500 Internal Server Error
              "Script Error
              Error:
              Amyuni Low Level Print:
              Layout name: [email protected][PathAlias.ADB_Path]\requests.ddd
              Layout type: report
              Invalid report filter expression: 'req_id =0'."

              So it looks like the variable for the req_id is not working. The req_id for the one I just submitted is 000096
              Land of the Free, Because of the Brave
              Support our US Military

              Comment


              • #8
                Re: email rpt for current record when click submit

                'req_id =0'."

                The stuff on the end is suspicious.
                There can be only one.

                Comment


                • #9
                  Re: email rpt for current record when click submit

                  yes that does look suspicious... it must be my syntax for the query.. but I have no idea how to fix
                  Land of the Free, Because of the Brave
                  Support our US Military

                  Comment


                  • #10
                    Re: email rpt for current record when click submit

                    So it looks like the variable for the req_id is not working. The req_id for the one I just submitted is 000096
                    To have 000096 the data type would have to be character. Your variable is DIM Req as N.

                    so rec_id can never equal var->req.
                    There can be only one.

                    Comment


                    • #11
                      Re: email rpt for current record when click submit

                      I noticed that too, and changed it to
                      DIM Req as C

                      I still got an error
                      Land of the Free, Because of the Brave
                      Support our US Military

                      Comment


                      • #12
                        Re: email rpt for current record when click submit

                        Same error?

                        With a character variable the line would be

                        query.filter = "req_id =" + quote(var->Req)
                        There can be only one.

                        Comment


                        • #13
                          Re: email rpt for current record when click submit

                          getting warmer.... I changed the query to what you suggested. I didn't get an error this time, and I got an email with an attachment, however the report says 'the report did not contain any records'.
                          Land of the Free, Because of the Brave
                          Support our US Military

                          Comment


                          • #14
                            Re: email rpt for current record when click submit

                            So now the problem is with the variable. I'm not into the web side of things but

                            Req = "{id}"

                            this looks to me like it assigns the text {id} to the req variable.

                            Add a line just after this, for testing

                            req = "000096"

                            and run it again.

                            If that gets a report with records you know you're not getting a valid value into req.
                            There can be only one.

                            Comment


                            • #15
                              Re: email rpt for current record when click submit

                              Did as you said, and yes, I got a report with the record 000096 displayed, and an email.

                              The data entry page web component has the field req_id listed, however it is not a field the user enters data in. It is an auto-increment field. I wonder if that is where the problem is?
                              Land of the Free, Because of the Brave
                              Support our US Military

                              Comment

                              Working...
                              X