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

Using checkbox select column and filtering with email.

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

    Using checkbox select column and filtering with email.

    I have set up a grid with the checkbox select column, and have added a button, that when people have selected some records by clicking in the check boxes, I can filter and only see the records that customers have selected.

    Question:
    After selected I want to create a button so that people can click on it and a email is send with those selected records in it, (This is a simple inventory program.), to the responsible person.

    Thanks
    Roelof

    #2
    Re: Using checkbox select column and filtering with email.

    I used an Action Button, placed in the Record Navigator/Grid Toolbar to run an Ajax Callback that runs this code.

    I think you'll need to get to the table in code in order to get the specific data for each row that is checked... not sure if you can get to the data directly. At least you have the keys and the rows. There are a few way to get an email message out - a search here will produce several options.

    Code:
    function Email_Recs as c (e as p)
    
    
    dim count as n
    dim emsg as c
    
    emsg = ""
    
    count = val(e.checkboxRows.countChecked)
    if count = 0 then
        dim cmd as c
        cmd = "alert('You did not check any rows');"
        CopyRec = cmd
        exit function
    end if
    dim i as n
    for i = 1 to count
    	emsg = emsg + e.checkboxRows.rows[i] + crlf()
    next i	
    
    dim pm as p
    pm.to = "[email protected]"
    pm.to_alias = "David"
    pm.from = "[email protected]"
    pm.from_alias = "[email protected]"
    pm.subject = "Grid Records Select Test Email"
    pm.message = emsg
    pm.attachments = ""
    
    email_send2(pm)
    
    
    
    end function

    Comment


      #3
      Re: Using checkbox select column and filtering with email.

      I copied the function into a button in the button action, I go into Text mode and copy the function that you gave me.

      I get an error, just clicking on the Working preview.
      It says: An error has occurred in the script on this page.
      Line 1231
      Char 44
      Error Expected '('
      Code 0

      Do you want to continue running scripts on this page.

      I am not a programmer so I don't know what the issue is.
      As soon as I remove the function everything works. I can click on the check box and filter the records.
      But with the code in it it crashes.



      Thanks
      roelof

      Comment


        #4
        Re: Using checkbox select column and filtering with email.

        This function needs to go into the grid under Properties, Xbasic Function Declarations.
        Then, in your button, add an Action Javascript, Ajax Callback, and put the name of the function (Email_Recs, if you kept the same name) into the function name, and without the parens ().

        Comment


          #5
          Re: Using checkbox select column and filtering with email.

          This is what I am getting at this point. I have followed your instructions but this is what comes up when I push the button:
          "Error executing Ajax callback function 'Email_Recs'. Error reported was: Function: 'Email_Recs' was not recognized "
          Sorry this does work I put it in the wrong box, I guess I did not follow your instructions.

          The only thing I get back is :
          1
          2

          So how do I get the record and the information in the record back?
          Last edited by Atta; 06-01-2011, 10:52 AM.

          Comment


            #6
            Re: Using checkbox select column and filtering with email.

            Yes, the only information being emailed in this example are the selected record row #'s. The attached images might help confirmed what goes where.

            To get the actual data from each record I think you have to open the associated table using xbasic and read the data from there. I'm not sure if there is a way to loop through the selected rows and get data from each row... have to look into that. Are you using SQL or DBF tables?
            Attached Files

            Comment


              #7
              Re: Using checkbox select column and filtering with email.

              Than you VERY much for that information. I got it to work like the pictures above. I am working now on getting the information in the email. I am using SQL

              Comment


                #8
                Re: Using checkbox select column and filtering with email.

                So I have found out that the records that it "filters" it stores the record# from my SQL table in e.checkedRows.key1...

                See picture:currentrow.JPG

                How can I get to that record in a loop, I cannot type e.checkedRows.key1[I]

                Because then the next step is that the record is e.checkedRows.key2[I] etc.

                So this works e.checkedRows.key1[i] but the next step through the loop is ARRAY INDEX OUT OF BOUNDS
                I hope this makes sense. If not please let me know.

                dim i as n
                for i = 1 to count
                emsg = emsg + e.checkboxRows.rows[i] + e.checkedRows.key[i]:[i] + crlf()
                next i

                Anybody can give me some pointers?

                Comment


                  #9
                  Re: Using checkbox select column and filtering with email.

                  I believe you need to go after the SQL table in order to get to the data in the rows selected. If it's just one row, then you'd have the variables for the current row available, but multiple rows will need a select statement. Here's some code that grabs the selects rows and selects from the table and builds a message.

                  Code:
                  function Email_Recs as c (e as p)
                  
                  dim count as n
                  dim emsg as c
                  dim conn as SQL::Connection
                  dim args as SQL::Arguments 
                  dim rs as SQL::ResultSet
                  dim count as n
                  dim sql as c
                  
                  emsg = ""
                  
                  count = val(e.checkboxRows.countChecked)
                  if count = 0 then
                      dim cmd as c
                      cmd = "alert('You did not check any rows');"
                      Email_Recs = cmd
                      exit function
                  end if
                  
                  'Build the Arguments set to pass in SQL stmt.
                  dim i as n
                  for i = 1 to count
                  	args.set("PKValue_R" + i + "_1", eval("e.checkedRows.key" + i + "[1]"))
                  next i	
                  
                  sql = "SELECT * FROM tblProducts WHERE " + e.checkboxFilter 
                  
                  if conn.Open("::Name::Connection","admin","PW") then
                  	 conn.PortableSQLEnabled = .f.
                  	 if conn.execute(sql,args) then
                  	 	rs = conn.ResultSet
                                 conn.close()
                       else
                           'could not execute redrirect to error
                         	  Email_Recs = "alert('Execution Problem');"
                            conn.close()
                            end
                       end if
                  else
                       Email_Recs = "alert('Connection Problem');"
                       end
                  end if
                  
                  while rs.NextRow()
                    emsg = emsg + rs.data("ProdId") + " " 
                  end while
                  
                  dim pm as p
                  pm.to = "[email protected]"
                  pm.to_alias = "David"
                  pm.from = "[email protected]"
                  pm.from_alias = "[email protected]"
                  pm.subject = "Grid Records Select Test Email"
                  pm.message = emsg
                  pm.attachments = ""
                  
                  email_send2(pm)
                  
                  end function

                  Comment


                    #10
                    Re: Using checkbox select column and filtering with email.

                    Thank you very much for this, how can I put in here that the customers email opens up with the information, ready to be send?
                    Because if I email it to me, then I do not know who needs it, or from whom it is coming. (I do not use security)

                    You are using
                    while rs.NextRow()
                    emsg = emsg + rs.data("Itemname"+"Qty") + crlf()
                    end while

                    With the above statement it comes up with an error, ( I have added the Qty)

                    In the xbasic but where is the rs.data, and how can I put more variables behind it.
                    When I click in the debugger on the RS it comes up with a whole lot of items, but the data has nothing?
                    Last edited by Atta; 06-04-2011, 09:54 PM. Reason: updated

                    Comment

                    Working...
                    X