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

Ideas needed for user-defined functions and session variables - Thanks!!

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

    Ideas needed for user-defined functions and session variables - Thanks!!

    I'm hoping for insight on the best way to approach my goals for having reusable user-defined xbasic functions and complications with session variables and a tabbed ui. The functionality I'm trying to deliver is to have the ability to basically build an email message with attachments that can be sent to a list of contacts (grid with a checkbox column). I have about 10 of these grids that allow the user to query their various data in many ways to come up with the special combination of email recipients. I have a button on the bottom of each grid that allows the user to build the email by opening a UX Component with a file upload control and two textarea controls (with ckeditor): one for the email body and one for the signature. These email fields come from list controls over the repository table that holds user-defined email content. After the user has made these three selections, I set session variables to hold their choices. Then there is a second button on the grid that will send the emails to all who are selected in the grid with the checkbox checked. This is an ajax callback to a user-defined xbasic function that I created that uses dotnet to actually send the emails with the attachments and appropriate email text.

    The problem I'm running into arises if the user opens one of the queries in a tab, sets up the email but doesn't send yet. They then open a different query and possibly click on the button that actually sends the emails. My session variables won't necessarily be what they want to construct the emails. Is there a way to have these two universal user-defined functions do the work I want them to do for all the queries but use some other kind of variable to store their selections in so that it doesn't matter if they have multiple instances of the ux component open (or if they are in mid-process of multiple queries and emails)? I don't even think this scenario is likely to happen, but obviously I want to provide a solution so it can't happen. I'll include the code here from my second function that does the work and maybe it will be more clear:

    function processdotnet as c (e as p)

    dim updcount as N
    dim validresult as l
    dim vfilter as c = ""
    dim checksCount as n
    dim planarray as c = ""
    dim oktosend as l

    dim subj as C
    dim body as C
    dim isHtml as L = .T. '.T. if body is HTML, otherwise .F.
    dim FileAttachment as C = ""
    '*******dim CC as C = "terri@xxxxxxx"
    dim Bcc as C = ""
    'If you want multiple recipients, CCs, or BCCs, you need to write FOR or FOR EACH loops
    ' to add them

    'parameters that are often static for a web site
    '******dim sender as C = "[email protected]"
    dim sender as C = "xxxxxxx.com"
    dim EmailServer as C = "xxxxxxx" 'put your server here
    dim EmailPort as N = 25 'usually 25 (plain) or 465 (SSL/TLS). 587 for GMail TLS.
    dim isSSL as L = .F. '.T. if SSL/TLS, .F. if not
    dim EmailUser as C = "xxxx"
    dim EmailPassword as C = "xxxxx"
    dim recipient as C = ""


    if val(e.checkboxRows.countChecked) > 0 then
    'First make sure they selected attachments and then build an array of attachments
    '---------- reformulate array from session variables

    dim session.arrayString as c
    dim session.arrayFormat as c
    dim arr[0] as p
    if session.arrayFormat <> "" .and. session.arrayString <> ""
    arr.initialize_properties(session.arrayFormat,session.arrayString)
    else
    processdotnet = "alert('Error, No attachments have been selected.');"
    end
    end if
    dim cn as sql::Connection
    DIM cr as sql::CallResult
    DIM updcr as sql::CallResult
    dim basers as sql::ResultSet
    dim args as SQL::Arguments
    dim cnflag as l
    dim updflag as l
    dim allflag as l
    dim sql as c = ""
    dim updsql as c = ""
    dim vemail as c
    cnflag = cn.open("::Name::cnNAISQL")
    cr = cn.CallResult
    if cnflag = .f. then
    processdotnet = "alert('Error, Connecting to database for generating emails. Error was: "+ cr.text + "');"
    end
    end if
    on error goto neterrors2

    'create a filter without arguments
    checksCount = val(e.checkboxRows.countChecked)
    for i = 1 to checksCount
    vFilter = vFilter + "autoid = " + eval("e.checkedRows.key" + i +"[1]") + "" +crlf()
    next i
    vFilter = alltrim(vFilter)
    vFilter = strtran(vFilter, crlf()," OR ")
    sql = <<%longstring%
    SELECT planinfo.AUTOID, planinfo.PLANID, planinfo.COMPANYID, planinfo.PLANNAME, planinfo.PYEMDY, planinfo.CLIENTDOCFOLDER, company.EMAIL
    FROM planinfo planinfo
    INNER JOIN company company
    ON planinfo.COMPANYID = company.COMPANYID
    WHERE
    %longstring%
    sql = sql + " " + vfilter

    allflag = cn.Execute(sql)
    cr = cn.CallResult
    if allflag = .f. then
    processdotnet = "alert('Error, Selecting plans. Error was: "+ cr.text + "');"
    cn.Close()
    end
    end if

    basers = cn.ResultSet
    baseflag=basers.NextRow()
    hourglass_cursor(.t.)
    updcount = 0

    'Cycle through the selected plans.
    while baseflag
    'create email with attachments
    oktosend = .T.
    'use the company email address to determine the recipient
    vemail=alltrim(basers.data("EMAIL"))
    recipient = ""
    if vemail <> "" then
    recipient = alltrim(basers.data("EMAIL"))
    else
    oktosend = .F.
    planarray = planarray + "<br>The email address for the company for " + alltrim(basers.data("planname")) + " is blank. "
    end if


    'Is this a valid email address? If not, don't try to send and add the error to the error string
    validresult = a5_is_email_valid(recipient)
    if validresult = .F. then
    oktosend = .F.
    planarray = planarray + "<br>The email address for " + alltrim(basers.data("planname")) + " is not a valid format: " + alltrim(recipient)+ "."
    end if

    if oktosend = .T. then
    dim msg as System::Net::Mail::MailMessage = new System::Net::Mail::MailMessage()
    msg.To.Add(recipient)
    msg.From = new System::Net::Mail::MailAddress(sender)
    msg.Subject = "Email for " + alltrim(basers.data("planname"))
    html_msg = <<%html%
    <html>
    <head> </head>
    <body>{session.varemailmessage}{session.varemailsig}

    </body>
    </html>
    %html%
    msg.Body = evaluate_string(html_msg)

    ' msg.Body = session.varemailmessage + session.varemailsig
    msg.BodyEncoding = System::Text::Encoding::UTF8
    msg.IsBodyHtml = isHtml
    msg.Priority = System::Net::Mail::MailPriority::Normal
    dim addrCC as System::Net::Mail::MailAddress = new System::Net::Mail::MailAddress(CC)
    msg.CC.Add(addrCC)
    'dim addrBcc as System::Net::Mail::MailAddress = new System::Net::Mail::MailAddress(Bcc)
    'msg.Bcc.Add(addrBcc)

    'Loop through the attachments array and add the attachments to the email
    dim count as n
    count = arr.size()
    dim i as n
    for i = 1 to count ' loop through filearray'
    msg.Attachments.Add(new System::Net::Mail::Attachment(arr[i].name))
    next
    dim MailClient as System::Net::Mail::SmtpClient = \
    new System::Net::Mail::SmtpClient(EmailServer,EmailPort)
    MailClient.EnableSsl = isSSL
    MailClient.UseDefaultCredentials = .F.
    MailClient.Credentials = new System::Net::NetworkCredential(EmailUser, EmailPassword)
    MailClient.Send(msg) 'this does the actual sending of email
    msg.Dispose() 'clean up
    updcount = updcount + 1


    else
    planarray = planarray + "<br>Email was not sent to " + alltrim(basers.data("planname")) + "."
    end if
    'when there are no more records in the resultset, executing nextrow will return .f.
    'so flag will be .f. and the while loop will end
    baseflag = basers.nextRow()
    end while
    cn.close()
    session.arrayString = ""
    session.arrayFormat = ""
    session.varemailmessage=""
    session.varemailsig=""
    processdotnet = "A5.msgBox.show('Results:','<div style=\'padding: 20px; width:600px;\' >Number of emails generated: " + js_escape(updcount) + "&nbsp;<br>&nbsp;" + js_escape(planarray) + "</div>','o');"
    else
    processdotnet = "A5.msgBox.show('Results','No plans were selected.','o');"
    end if
    end
    neterrors2:
    dim err_msg as c
    line = error_line_number_get()
    script = error_script_get()
    err_msg = error_text_get(error_code_get())+ ". An error occurred at line "+ alltrim(str(line,4,0)) + " in script: " + script
    processdotnet = "A5.msgBox.show('Error:','"+js_escape(err_msg)+"','o');"
    end function

    #2
    Re: Ideas needed for user-defined functions and session variables - Thanks!!

    Anyone? I have a feeling I just need to be set in the right direction to accomplish this...

    Thanks in advance for any help you could provide!
    Lisa

    Comment


      #3
      Re: Ideas needed for user-defined functions and session variables - Thanks!!

      Seems like you are concerned about the session variables holding the data, so why not store the info you need in a table instead? Give each message an id, a user, a status like "building, pending, sent,cancelled" and a message result. Then the user can store up as many as they want and send whenever it is convenient. They could also start then stop then finish later, or resend if they have revisions. You will also have a history of what's been sent.

      You've got the hard part done already. Just create your message queue.

      Pat
      Pat Bremkamp
      MindKicks Consulting

      Comment


        #4
        Re: Ideas needed for user-defined functions and session variables - Thanks!!

        Thank you SO much, Pat! I will take your suggestion and run with it. Sometimes the hard part is not knowing what you don't know. Is it a design issue or an *obvious* programmatic solution (that I don't know)? At least I feel like I'm not missing some easy solution through some special variable type or something. Again, thank you for your help.

        Lisa

        Comment

        Working...
        X