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

Automatic PDF attachment via Email

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

    Automatic PDF attachment via Email

    I have a grid which allow you to select multiple records from a search result using checkboxes. I identify each chosen record by a TRUE result together with the current DATE.

    Now when i select SUMBIT i need a PDF report generated showing the selected (checked) items and that report to be emailed to a person in the contacts table where sign-off rights is TRUE.

    Is this possible? If so can someone please point me in the right direction.

    I have looked at 1.14 in the web apps demo which creates the PDF and 2.3 which creates the email, but i am really stuck on how to incororate the two functions upon pressing the SUBMIT button in my grid.
    Last edited by den1s; 08-18-2006, 12:27 PM.

    #2
    Re: Automatic PDF attachment via Email

    Please find attached my current progress.

    So to recap...

    This application allows a user to identify what items should be disposed of and automatically emails the cost center manager for sign off approval.

    I have a grid that allows you to select multiple records from a search result using checkboxes. I identify each chosen record by a TRUE result together with the current DATE.

    The issue

    Now when I select SUMBIT I need a PDF report generated showing the selected (checked) items and that report to be automatically emailed to the cost center manager in the contacts table where sign-off rights is TRUE.

    Please see attached testdb.

    Any help will really be appreciated.

    Comment


      #3
      Re: Automatic PDF attachment via Email

      Has anyone achieved any part of this. Any help with any part would be wonderful.

      Comment


        #4
        Re: Automatic PDF attachment via Email

        Bump!

        Comment


          #5
          Re: Automatic PDF attachment via Email

          This works - here is my AfterValidate code under my Submit Application dialog.

          Code:
          ' report
          dim filter as c 
          dim order as c 
          Filter = "Job_ID="+quote(session.job_id)
          Order = "Job_id"
          ' EMAIL PRODUCTION
          Dim filename as c 
          filename = session.session_folder + chr(92) + session.customer_id + "_" + session.c + "_trustapp.pdf"
          filename = report.saveas("<A href="mailto:tr_trusts@[PathAlias.ADB_Path]\tr_trust_master_set.set","pdf",filter,order,filename,.f">tr_trusts@[PathAlias.ADB_Path]\tr_trust_master_set.set","pdf",filter,order,filename,.f.)
          if file.exists(filename) 
           'currentform.RedirectTarget = session.session_url + "tempreport.pdf?" +  time("hms3")
          end if  
          dim e_attach as c
          dim e_to as c
          dim e_cc as c
          dim e_prof as c
          dim e_body as c
          dim e_subj as c
          email_profile = lookup("<ADB_Path>\global_defaults",".t.","Email_profile")
          e_to = lookup("<ADB_Path>\customers","Customer_ID="+quote(session.customer_ID),"Email")
          e_cc = ""
          e_bcc = ""
          e_subj  = "New online trust app for " + session.c
          e_body  = "You have submitted a trust to ATS for production. We will review and either start production, or" \
            + " call you with questions. A copy of the trust application is attached." + crlf(2) + "Internal Job_ID: " + session.job_id + crlf() + "Customer ID: " + session.customer_ID + crlf() + "Client: " + session.c
          e_attach = filename
          email_send(e_to,e_subj,e_body,e_attach,e_cc,e_bcc,.F.,"","")
          'redirect
          response.redirect("tr_submit_ok.a5w")
          Steve Wood
          See my profile on IADN

          Comment


            #6
            Re: Automatic PDF attachment via Email

            Steve,

            Thank you for your reply. I have run through your code and it looks like what i am looking for.

            Although i am becoming a little more comfortable with xbasic, i cannot truly understand the functionality of all the code, i wonder if you could point out where in the code i will need to modify.

            Also my big question is, will this work in a grid event?

            Thanks again.

            Denis

            Comment


              #7
              Re: Automatic PDF attachment via Email

              It would probably work in a grid event, but I have never seen those events as places to stick large amounts of code. You could place all of your code in the done.a5w page that you must be opening after they click submit on the grid. If you update the records with some sort of flag indicating you want to send an email to those individuals, then you can filter on this in done.a5w.

              Or, if you are trying to let users choose wich record to email, then you can add a link to the grid that, when clicked, goes to an a5w page that fires off the email based on URL parameters in the link, and then returns you to the grid. I'm suggesting this without actually testing the theory, but this is how some users are including a link that Prints individual records.
              Steve Wood
              See my profile on IADN

              Comment


                #8
                Re: Automatic PDF attachment via Email

                Thanks for all the options Steve.

                I will start from the top and see what works the best.

                Starting with the code, I have taken out bits of your code to create the following.

                Code:
                function AfterUpdateRecords as v (Args as P, PageVariables as P)
                with PageVariables
                
                'Create session variable for filter field
                dim session.request_no as c
                session.request_no = Args.DataSubmitted.R1.REQUEST_NO
                
                'Save Report to File
                name = "rptassets@[PathAlias.ADB_Path]\assets.ddd"
                format = "PDF"
                filter = "request_no="+quote(session.request_no)
                order = ""
                filename = "c:\test.pdf"
                report.saveas(name,format,filter,order,filename,.F.)
                
                'E-Mails Report as Attachment
                addr = "[email protected]"
                subject = "Disposal Request Submitted"
                body = "msg body"
                email_send(addr,subject,body,filename,"","",.T.,"HTML","","Default",.F.,.T.)
                end with
                end function
                The problem i have so far is with the filter. I am tryig to use a session variable as the filter, but for some unknown reason am getting the following error. This does not happen if i hard code the filter result or remove the filter altogether.

                500 Internal Server Error
                Script Error
                Error:File not found: 'c:\test.pdf'

                The file does exist. However, without the filter, the file is created anyway.

                Comment


                  #9
                  Re: Automatic PDF attachment via Email

                  Its probably a difference in field type. session vars are charactor vars, you may need to use convert_type() function.

                  Also are you sure the session.request_no get populated when a record is updated?

                  Unless you need it outside of this function, you don't need to use a session var, just filter=Args.DataSubmitted.R1.REQUEST_NO (with possible need for convert_type() in there.

                  I know you are just testing, but you need several error checking statements in case the email fails, file not found (for legit reasons), etc.
                  Steve Wood
                  See my profile on IADN

                  Comment


                    #10
                    Re: Automatic PDF attachment via Email

                    Hi Steve,

                    I have implemented all the code in an AfterUpdateEvent and i am pleased to say is working... almost!

                    I am now trying to get your code to work for me (see below).

                    Code:
                    email_profile = lookup("<ADB_Path>\global_defaults",".t.","Email_profile")
                    e_to = lookup("<ADB_Path>\customers","Customer_ID="+quote(session.customer_ID),"Email")
                    I have a table that holds all the contact information called CONTACTS with 'user_id' (n), dept_no' (c) and 'email' (c) amongst the fields.
                    I have another table called ASSETS with 'asset_id' (n), 'manager' (l) and 'dept_no' (c) amongst the fields.

                    c = character l = logical n = numeric

                    When a user clicks on the relevent assets, each asset has a 'dept_no' assigned to it.

                    What i am trying to achieve within the code is

                    Lookup the email addresses within the contacts table where the cost center is equal to the cost center for each asset selected and email the MANAGER.
                    where manager is TRUE for that cost center.

                    How can i manipulate your code to make this work.

                    Thanks

                    Denis

                    Comment


                      #11
                      Re: Automatic PDF attachment via Email

                      Sorry I have not responded but its kind of an involved question and it looks like the answer, and the programming, is a lot of work (looping through records, posting records to a temp table to email 'later' else your user will have to sit there while each email spawns, etc.).

                      I might be up to it next week or so but right now I am finishing up a program for a FEMA contractor where the deadline is that actual live hurricane in the Atlantic.
                      Steve Wood
                      See my profile on IADN

                      Comment


                        #12
                        Re: Automatic PDF attachment via Email

                        No probs Steve. Thanks for your help so far.

                        Comment


                          #13
                          Re: Automatic PDF attachment via Email

                          Steve,

                          Due to the complexity of this type of functionality, i have revised my expectations. In order to simplify this process i wish to change the functionality to allow the user to choose who the email goes to via a standard dropdown list. I have looked at this but cannot seem to create it.

                          In the afterupdate event of the grid i have the following code to generate a report based on the choices made.

                          Code:
                          'Save Report to File
                          IF eval_valid("dasset_id")= .f. then
                             goto skipreport
                          end if
                          
                          dim filter as c
                          dim order as c
                          dim aid as C
                          dim filename as C
                          
                          aid = dasset_id.dump()
                          aid = remove_blank_lines(aid)
                          aid = *for_each(x,"asset_id = " + quote(x),aid)
                          filter = stritran(alltrim(aid), crlf(), " .or. ")
                          Order = ""
                          
                          'filename = session.session_folder + "tempreport.pdf"
                          filename = "C:\Documents and Settings\Denis\My Documents\Alpha Reports" + chr(92) + "tempreport" + rand() + rand() + ".pdf"
                          filename = report.saveas("rptassets@<adb_path>\assets.ddd","pdf",filter,order,filename,.f.)
                          if file.exists(filename)
                          	currentform.RedirectTarget = session.session_url + "tempreport.pdf?" + rand_string(5) 
                          else
                              ? "The PDF file (" + filename + ") was not created."
                          end if
                          skipreport:
                          Now i need to have a diaglog or grid opened so that the user can choose who to email this report to.

                          I have looked at some examples, but i am not sure how to populate "to:" and "filename" options.

                          Any help on this would be great.

                          Denis

                          Comment


                            #14
                            Re: Automatic PDF attachment via Email

                            Steve,

                            No worries. I have sorted this problem out.

                            Thanks for the help you gave for this thread.

                            Denis

                            Comment

                            Working...
                            X