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 onSave

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

    email onSave

    I have an embeded browse - example in jpg below. It has a few colour equation columns and also a button which sends an email. It all works well and I would now like to have the email automatically sent when the colour equation is satisfied. I am thinking this might be via an onSave event, but I don't know how to marry the expression with the code - or even if I'm going in the best direction. Examples of my current expression and email code are below.

    Many thanks.

    1.JPG


    Example colour equation:
    (Call_Detail->Date_Op<=(previous("Call_Detail->Date_Op")+7))
    .AND.(previous("Call_Detail->Code")="EM".AND.Call_Detail->Code="EM")


    email code:
    this.Set_Viewport_row(row)
    if this.Table_Get().Mode_Get() > 0 then
    this.Commit()
    end if
    function Actions_ButtonClick as v( event as C,data as C, row as N)
    'get value into variable
    dim compiled_values as C
    compiled_values="Company: " + parentform:Browse1:Company.value +chr(10)
    ' + "Add1: " + parentform:Browse1:add1.value +chr(10) + "Town: " + parentform:Browse1:town_city.value +chr(10)
    msgbox(compiled_values)
    'email the info
    dim pm as P
    dim ps as P
    if (email_smtp_open(ps,"mail.m-press.biz", 25, "lgordon", "mrmmouse")) then
    pm.to = "[email protected], [email protected]"
    pm.cc = "[email protected]"
    pm.from = "[email protected]"
    pm.subject = "Alpha Message"
    pm.message = compiled_values
    pm.attachments = ""
    'pm.html_message = "<b>New Service Call</b>"
    email_smtp_send(pm,ps)
    end if
    email_smtp_close(ps)
    end function

    #2
    Re: email onSave

    Should be as simple as

    if (Call_Detail->Date_Op<=(previous("Call_Detail->Date_Op")+7)) .AND. (previous("Call_Detail->Code")="EM".AND.Call_Detail->Code="EM")
    ''your email code here
    end if
    There can be only one.

    Comment


      #3
      Re: email onSave

      Larry,

      Try this to see if it helps. Change some of the relation fields to "daughter" and move to another record. That's what the color equation and cansave code fire on. Presently all the event code does is display a message box.

      Actually the cansave or onsave is going to fire on any change to a record whether the color equation fires or not. The event code will only be executed if the color equation expression evaluates to true. In other words, if you make a change to a field not involved in the color equation in a record whose color is currently white on red and you code the event for the expression that yields red on white, the cansave still fires and the if...end if is satisfied - email will be sent.

      I've modified the sample database to capture the "state" of the colored browse field in the onfetch event and use that to determine whether or not to execute the code in the onsave event. If the color equation is satisfied when the record is fetched then one doesn't want to execute the action if a different field is changed.
      Attached Files
      Last edited by Stan Mathews; 03-19-2014, 08:31 AM.
      There can be only one.

      Comment


        #4
        Re: email onSave

        Thanks very much for your time and help Stan. My apologies for not replying yesterday but unfortunately I had issues with the RDP connection to my office desktop where my Alpha resides.

        Regarding your final paragraph, I regret I can't find the onfetch event you refer to, though I understand your logic.

        Meanwhile, having gratefully adopted your message box idea I was able to locate my first problem. Whilst the color equation worked insofar as it changes the background field color in the browse, it did not trigger the message box function - which I placed into the code directly below the color expression. By a process of elimination, I eventually found that by removing one part of my expression, the message triggered. The item I removed was: .AND.(previous("Call_Detail->Code")="EM"
        I still cannot see why inclusion of this equation stops the message box function. The remaining code, which does successfully trigger the message, is now:

        if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"

        Moving on, now that the message box is working, I attached my email code and... nothing. I appreciate that the email code that I copied is driven by the button in the same browse - where it works correctly - so I have tried modifying the code in several ways to fit it in with the equation but to no avail. I have therefore restored the email code to its original format and was hoping that you might help me correct it... This is my starting point:

        if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
        ui_msg_box("Service Note","This call has triggered the escalation procedure")
        end if
        'my current BUTTON email code
        this.Set_Viewport_row(row)
        if this.Table_Get().Mode_Get() > 0 then
        this.Commit()
        end if
        function Actions_ButtonClick as v( event as C,data as C, row as N)
        'get value into variable
        dim compiled_values as C
        compiled_values="Company: " + parentform:Browse1:Company.value +chr(10) + "Model: " + parentform:Browse1:model.value +chr(10)+ "Serial No: " + parentform:Browse1:Ser_No.value+chr(10)+ "Service Code: "+ parentform:Browse1:code.value+chr(10)+ "Detail: "+ parentform:Browse1:item.value+chr(10)+ "Placed by: "+ parentform:Browse1:pl_by.value+chr(10)+ "Engineer: "+ parentform:Browse1:eng.value
        ' + "Add1: " + parentform:Browse1:add1.value +chr(10) + "Add2: " + parentform:Browse1:add2.value +chr(10) + "Town: " + parentform:Browse1:town_city.value +chr(10) + "County: " + parentform:Browse1:county.value +chr(10) + "Post Code: " + parentform:Browse1:P_code.value +chr(10) + "Tel: " + parentform:Browse1:mc_tel.value +chr(10)
        msgbox(compiled_values)
        'email the info
        dim pm as P
        dim ps as P
        if (email_smtp_open(ps,"mail.m-press.biz", 25, "lgordon", "PASSWORD")) then
        pm.to = "[email protected]"
        pm.cc = ""
        pm.from = "[email protected]"
        pm.subject = "Alpha Message"
        pm.message = compiled_values
        pm.attachments = ""
        'pm.html_message = "<b>New Escalation Call</b>"
        email_smtp_send(pm,ps)
        end if
        email_smtp_close(ps)
        end function

        Comment


          #5
          Re: email onSave

          There's nothing wrong with your code other than it is waiting for a buttonclick that doesn't happen. When placed on an event such as cansave you need to simply execute the code (I suppose you could trigger the function with a call to it but that would confuse things if you ever have to revisit it).

          I think you can replace my msgbox() substitute with your code stripped of the function declaration.

          Code:
          'my current BUTTON email code
          if this.Table_Get().Mode_Get() > 0 then
          this.Commit()
          end if
          'get value into variable
          dim compiled_values as C
          compiled_values="Company: " + parentform:Browse1:Company.value +chr(10) + "Model: " + parentform:Browse1:model.value +chr(10)+ "Serial No: " + parentform:Browse1:Ser_No.value+chr(10)+ "Service Code: "+ parentform:Browse1:code.value+chr(10)+ "Detail: "+ parentform:Browse1:item.value+chr(10)+ "Placed by: "+ parentform:Browse1:pl_by.value+chr(10)+ "Engineer: "+ parentform:Browse1:eng.value
          ' + "Add1: " + parentform:Browse1:add1.value +chr(10) + "Add2: " + parentform:Browse1:add2.value +chr(10) + "Town: " + parentform:Browse1:town_city.value +chr(10) + "County: " + parentform:Browse1:county.value +chr(10) + "Post Code: " + parentform:Browse1:P_code.value +chr(10) + "Tel: " + parentform:Browse1:mc_tel.value +chr(10)
          msgbox(compiled_values)
          'email the info
          dim pm as P
          dim ps as P
          if (email_smtp_open(ps,"mail.m-press.biz", 25, "lgordon", "PASSWORD")) then
          pm.to = "[email protected]"
          pm.cc = ""
          pm.from = "[email protected]"
          pm.subject = "Alpha Message"
          pm.message = compiled_values
          pm.attachments = "" 
          'pm.html_message = "<b>New Escalation Call</b>"
          email_smtp_send(pm,ps)
          end if
          email_smtp_close(ps)
          There can be only one.

          Comment


            #6
            Re: email onSave

            To illustrate the other thought, calling the function, this should also work. Your email code doesn't use the parameters passed to the Actions_ButtonClick() function so in supplying values we only need the proper data type.

            Code:
            if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
            ui_msg_box("Service Note","This call has triggered the escalation procedure")
            end if
            
            'my current BUTTON email code
            this.Set_Viewport_row(row)
            if this.Table_Get().Mode_Get() > 0 then
            this.Commit()
            end if
            [COLOR="#FF0000"]Actions_ButtonClick("onsave","junk",row)[/COLOR]
            
            function Actions_ButtonClick as v( event as C,data as C, row as N)
            'get value into variable
            dim compiled_values as C
            compiled_values="Company: " + parentform:Browse1:Company.value +chr(10) + "Model: " + parentform:Browse1:model.value +chr(10)+ "Serial No: " + parentform:Browse1:Ser_No.value+chr(10)+ "Service Code: "+ parentform:Browse1:code.value+chr(10)+ "Detail: "+ parentform:Browse1:item.value+chr(10)+ "Placed by: "+ parentform:Browse1:pl_by.value+chr(10)+ "Engineer: "+ parentform:Browse1:eng.value
            ' + "Add1: " + parentform:Browse1:add1.value +chr(10) + "Add2: " + parentform:Browse1:add2.value +chr(10) + "Town: " + parentform:Browse1:town_city.value +chr(10) + "County: " + parentform:Browse1:county.value +chr(10) + "Post Code: " + parentform:Browse1:P_code.value +chr(10) + "Tel: " + parentform:Browse1:mc_tel.value +chr(10)
            msgbox(compiled_values)
            'email the info
            dim pm as P
            dim ps as P
            if (email_smtp_open(ps,"mail.m-press.biz", 25, "lgordon", "PASSWORD")) then
            pm.to = "[email protected]"
            pm.cc = ""
            pm.from = "[email protected]"
            pm.subject = "Alpha Message"
            pm.message = compiled_values
            pm.attachments = "" 
            'pm.html_message = "<b>New Escalation Call</b>"
            email_smtp_send(pm,ps)
            end if
            email_smtp_close(ps)
            end function
            Here the line Actions_ButtonClick("onsave","junk",row) calls/executes the function just as STR(12345,10,2) converts a number to a character string.
            Last edited by Stan Mathews; 03-20-2014, 11:05 AM. Reason: spelling
            There can be only one.

            Comment


              #7
              Re: email onSave

              I can't keep up with you Stan! I've just finished working with the code at post #5. You are of course correct - the email was generated. Unfortunately it then was then repeated another 44 times and then the application froze. I apostrophied out the equation and it still sent about 45 emails on changing any field within the browse. I think you mentioned this in post # 3.

              I'm just going to study your most recent post and will report back. I thank you very much indeed for your time.

              Comment


                #8
                Re: email onSave

                Regarding your final paragraph, I regret I can't find the onfetch event you refer to, though I understand your logic.
                Attached Files
                There can be only one.

                Comment


                  #9
                  Re: email onSave

                  Sorry Stan. I thought you meant you had put code into the onfetch event in your sample database - that's what I couldn't find.

                  Re post #6, I have pasted in the new code. Now, on changing a field to satisfy the expression, the message triggers but then the following error message appears:

                  Script:CanSave line:10
                  this.Set_Viewport_row(row)
                  Variable "row" not found

                  Comment


                    #10
                    Re: email onSave

                    That's part of the button code we really don't need. Just delete the whole section

                    this.Set_Viewport_row(row)
                    if this.Table_Get().Mode_Get() > 0 then
                    this.Commit()
                    end if

                    and replace it with

                    parentform.commit()
                    There can be only one.

                    Comment


                      #11
                      Re: email onSave

                      My apologies for being such a nuiscance; now I'm getting:

                      Script:CanSave line:16
                      Actions_ButtonClick("onsave","junk",row)
                      Variable "row" not found.

                      Comment


                        #12
                        Re: email onSave

                        I thought you were using the first version rather than the second. Since there is no row available from the button click data and it's not being used, we should be able to supply any number.

                        Actions_ButtonClick("onsave","junk",1)

                        is good.
                        There can be only one.

                        Comment


                          #13
                          Re: email onSave

                          Getting there!
                          On changing a browse record which satisfies the equation it all works perfectly, i.e. message obox appears and then the email is sent. However, any change in the browse triggers the email. My current code is:

                          if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
                          ui_msg_box("Service Note","This call has triggered the escalation procedure")
                          end if

                          'email code
                          parentform.commit()
                          Actions_ButtonClick("onsave","junk",1)

                          function Actions_ButtonClick as v( event as C,data as C, row as N)
                          'get value into variable
                          dim compiled_values as C
                          compiled_values="Company: " + parentform:Browse1:Company.value +chr(10) + "Model: " + parentform:Browse1:model.value +chr(10)+ "Serial No: " + parentform:Browse1:Ser_No.value+chr(10)+ "Service Code: "+ parentform:Browse1:code.value+chr(10)+ "Detail: "+ parentform:Browse1:item.value+chr(10)+ "Placed by: "+ parentform:Browse1:pl_by.value+chr(10)+ "Engineer: "+ parentform:Browse1:eng.value
                          ' + "Add1: " + parentform:Browse1:add1.value +chr(10) + "Add2: " + parentform:Browse1:add2.value +chr(10) + "Town: " + parentform:Browse1:town_city.value +chr(10) + "County: " + parentform:Browse1:county.value +chr(10) + "Post Code: " + parentform:Browse1:P_code.value +chr(10) + "Tel: " + parentform:Browse1:mc_tel.value +chr(10)
                          msgbox(compiled_values)
                          'email the info
                          dim pm as P
                          dim ps as P
                          if (email_smtp_open(ps,"mail.m-press.biz", 25, "lgordon", "OKthats123")) then
                          pm.to = "[email protected]"
                          pm.cc = ""
                          pm.from = "[email protected]"
                          pm.subject = "Alpha Message"
                          pm.message = compiled_values
                          pm.attachments = ""
                          'pm.html_message = "<b>New Escalation Call</b>"
                          email_smtp_send(pm,ps)
                          end if
                          email_smtp_close(ps)
                          end function

                          Comment


                            #14
                            Re: email onSave

                            Now go back to my sample database and examine the variable creation in the onfetch event which determines whether or not the color equation is satisfied for the record being fetched. If it has we don't want the email sent.

                            Your wrapping if for the onsave or cansave needs to check that variable (dimmed as shared in both scripts).

                            if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM" .and. (.not. already set_variable)

                            Change the above to whatever you name already set_variable

                            In other words, code the onfetch event

                            dim shared already set_variable as L
                            already set_variable = .F. 'don't think this was in my original but is needed
                            if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
                            already set_variable = .t.
                            end if
                            Last edited by Stan Mathews; 03-20-2014, 01:07 PM.
                            There can be only one.

                            Comment


                              #15
                              Re: email onSave

                              I'm looking at the onfetch event for the browse in the sample database, but regret I still can't find any code. Am I looking in the wrong place?

                              onfetch.jpg

                              Comment

                              Working...
                              X