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

    #16
    Re: email onSave

    That's strange, it's in mine. Attaching again.
    Attached Files
    There can be only one.

    Comment


      #17
      Re: email onSave

      OK. I still think we are nearly there, but still getting email sent on any field change in browse, even outside expression parameters. It might be an idea if I review both sets of code for any obvious typo's.

      My onfetch code is now:

      dim shared col_mr as L
      col_mr = .F.
      if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
      col_mr = .t.
      end if

      My cansave code is:

      dim shared col_mr as L
      if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM" .AND. (.not. col_mr)
      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", "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


        #18
        Re: email onSave

        That's it. Should wrap the whole thing in the if.


        Code:
        dim shared col_mr as L
        if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM" .AND. (.not. col_mr)
        ui_msg_box("Service Note","This call has triggered the escalation procedure")
        'email code
        parentform.commit()
        Actions_ButtonClick("onsave","junk",1)
        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
        There can be only one.

        Comment


          #19
          Re: email onSave

          It is now working - most of the time, i.e. it all worked perfectly on raising my first two records, but on the third new record I raised,which should have triggered an email, the record saved and closed without an email being sent. I'm not sure why. I will do further testing and try to establish the issue.

          I do have one observation/concern though. In the cansave code at the end of line 7, by inserting or removing a space after the .AND. it and the following brackets turn green or black, as per the images below. With the space inserted and the .AND. being black, the event fails completely. Please excuse my ignorance, but is this significant?
          1.jpg 2.jpg

          Comment


            #20
            Re: email onSave

            You've named the shared variable the same as a table field. That may be confusing the script.

            Either rename it in both scripts (just put a v in front) or try referencing it with

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

            Edit: I do see the color change but the script compiles ok either way. Don't know why your're seeing a failure with the space inserted.
            Last edited by Stan Mathews; 03-20-2014, 04:39 PM.
            There can be only one.

            Comment


              #21
              Re: email onSave

              Have accordingly renamed the variable and also referenced it and I think its all OK now - though removing/inserting the space still changes the colour as before. I will thoroughly test tomorrow and report back. (Got to go for my dinner now!)

              Very many thanks for your fantastic help.

              Comment


                #22
                Re: email onSave

                Still progressing Stan, though I have made a few more schoolboy errors along the way! Firstly I renamed the shared variable in my cansave code as advised, but forgot to change it in the onfetch code. I also thought I was getting 'spurious' emails triggered, but these were because I then found these occurred if the col_mr field was blank, as that also satisfies the filter code, so have now added a >0 requirement, and it works properly. I am now trying to add the other fields that have colour equations.

                The problem I can't solve is with the 'Call_Detail->Date_Op' field. It works in the colour equation, i.e. triggers the red colour change, but does not trigger an email from the event. (I copied and pasted the code so syntax is the same). My whole cansave 'if' statement is now as follows:

                if ((Call_Detail->Date_Op<=(previous("Call_Detail->Date_Op")+7)).OR. (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100).AND.Call_Detail->Col_Mr>0)).AND.Call_Detail->Code="EM" .AND. (.not. vcol_mr)

                I have also copied the same filter code into the onfetch event and that is my second query: should I be keeping the 'if' filter the same in both events? Regarding the Date_op field problem, I think my next move is to strip the 'if' statement right back until I can get the date_op equation triggering emails.

                Comment


                  #23
                  Re: email onSave

                  should I be keeping the 'if' filter the same in both events?
                  The if in the onfetch should not have vcol_mr in it, rather it determines how to set vcol_mr. The if in the cansave uses that setting to determine whether or not to send an email. If vcol_mr is already true, don't send.
                  There can be only one.

                  Comment


                    #24
                    Re: email onSave

                    Sorry, I wasn't clear in my previous post. I do indeed only have the vcol_mr in the cansave statement as per your example.

                    I'm now finding another problem. When I add another equation to the statement, taking it to 450 characters in length, on triggering the cansave event, I get an error message stating that there are characters missing from my if statement towards the end. I've looked at the documentation and expressions can be much longer than 450 characters, so I'm not sure what is going on here. Is it OK to keep extending a line of code?

                    Comment


                      #25
                      Re: email onSave

                      You should be able to build an expression to 1023 characters (one reason to keep table and field names as short as possible).

                      I get an error message stating that there are characters missing from my if statement towards the end
                      Probably an error in the construction.
                      There can be only one.

                      Comment


                        #26
                        Re: email onSave

                        I regret that I've had to leave this for a few days - but I'm back! I was starting to go round in circles so I've decided to go back to basics. I've trimmed my expressions back as follows:

                        Current onfetch event is:
                        vcol_mr = .F.
                        if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
                        vcol_mr = .t.
                        end if

                        Current onsave event is:
                        dim shared vcol_mr as L
                        if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM" .AND. (.not. vcol_mr)
                        ui_msg_box("Service Note","Date Escalation Triggered")
                        'And then the email code follows here

                        On inputting the new record 'test 3' in the jpeg below, the message and email are triggered, even though the record does not satisfy the expression, i.e. the Code field is 'TD' and not 'EM'.

                        I don't know why this is happening as I'm sure we did have it working before.

                        Test3.jpg

                        Comment


                          #27
                          Re: email onSave

                          You need

                          dim shared vcol_mr as L


                          in the onfetch, otherwise you're not changing the shared variable. The onsave is reacting to the last value placed in the shared variable.
                          There can be only one.

                          Comment


                            #28
                            Re: email onSave

                            Sorry Stan. My mistake - I omitted the first line. My actual current onfetch is:

                            dim shared vcol_mr as L
                            vcol_mr = .F.
                            if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM"
                            vcol_mr = .t.
                            end if

                            Comment


                              #29
                              Re: email onSave

                              Started to make some progress again. I had been trying to use onsave event but am now back in cansave, where it works, sort of...
                              Current cansave code is:

                              dim shared vcol_mr as L
                              if (Call_Detail->Col_Mr<=(previous("Call_Detail->Col_Mr")+100)).AND.Call_Detail->Code="EM" .AND.Call_Detail->Col_Mr>0 .AND. (.not. vcol_mr)
                              ui_msg_box("Service Note","Colour Volume Escalation Triggered")
                              parentform.commit()
                              Actions_ButtonClick("onsave","junk",1)
                              end if
                              'email code follows

                              But I've now stumbled across a new challenge. If my Call_Detail->Col_Mr increases from say 60 to 65, the equation correctly triggers. However, it appears that if the same field increases from 995 to 999 it doesn't fire - even though I believe the equation is still satisfied and it should trigger. As I've said before, the colour equations all work, and with any number of digits. Am I missing something, i.e. should I be defining field sizes for the cansave equation?

                              Comment


                                #30
                                Re: email onSave

                                Anything that changes a value triggers the cansave and onsave events. Doesn't matter whether is it by 1 or 5.

                                More accurate to say that changing a value and moving to another record fires the cansave and onsave. The color equation will affect the browse cell immediately upon moving out of the cell even when staying in the same row.
                                Last edited by Stan Mathews; 04-03-2014, 11:45 AM.
                                There can be only one.

                                Comment

                                Working...
                                X