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

setting a forms Field values in Xbasic

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

    setting a forms Field values in Xbasic

    I have a grid. In this grid I have a field called "reportfilename" and a button.
    for the buttons Onclick I do an ajax callback (and compute current row data is checked) that calls an xbasic function to set some session variables.
    I see in the debugger that my variables are set and do contain the correct values. Doing good so far!
    Next
    I want to set a fields value in my form to one of the session variables in the xbasic and for the life of me I cannot do it.
    I have tried every way I can think of but obviously NOT the right one.

    Can one of you guys help me?
    The current xbasic function reads as this:

    function setmailedto as c (e as p)
    session.mailto = e._currentRowDataNew.EMAIL
    session.sentto = session.mailto + " " + Date() + " " + Now()
    e._set.reportfilename.value = "session.sentto"
    end function


    Now, the e.set thing fails to set the value of the field called "reportfilename" to the value of the session variable. The variable does have the correct value in the debugger so I dunno what I am supposed to do to get the value of the variable "session.sentto" set as the value for the field "reportfilename".
    The purpose of the date and Now are to add WHEN the email was sent...

    Help me learn! please!
    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

    #2
    Re: setting a forms Field values in Xbasic

    e._set.reportfilename.value = "session.sentto"
    should be like
    e._set.reportfilename.value = session.sentto

    however you are getting the value from the grid and setting the value in the grid itself, so you don't need to reconstruct using session variable you can just add it to the desired string.
    secondly you want to combine date() and now(), now() alone should be enough. debug thru and see if it gives what you need.

    Code:
    function setmailedto as c (e as p)
    session.mailto = e._currentRowDataNew.EMAIL
    e._set.reportfilename.value = e._currentRowDataNew.EMAIL+ " " + now()
    end function
    can be written like this
    you are using session variable for some other purpose. you can still have it available.
    Last edited by GGandhi; 08-15-2015, 03:58 AM.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    [email protected]
    Skype:[email protected]
    1 914 924 5171

    Comment


      #3
      Re: setting a forms Field values in Xbasic

      you are using ajaxcallback which involves trip to the server you can set the variables in the browser itself with inline javascript. probably faster does not require trip to server.

      Code:
      var email = {grid.object}.getValue('G','EMAIL',{Grid.RowNumber});
      var d1 = new Date();
      d1 = d1.toFormat('MM/dd/yyyy 0h:0m:0s AM');
      var emailSent = email+ " " + d1;
      {grid.object}.setValue('G','REPORTFILENAME',{Grid.RowNumber},emailSent);
      var session.email = email;
      thanks for reading

      gandhi

      version 11 3381 - 4096
      mysql backend
      http://www.alphawebprogramming.blogspot.com
      [email protected]
      Skype:[email protected]
      1 914 924 5171

      Comment


        #4
        Re: setting a forms Field values in Xbasic

        Your code will not work in xbasic syntax is
        var ="javascript here";
        so simply inserting this code will not work.

        Also I did try removing the quote marks around the "session.sentto" and that did not work either.
        NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

        Comment


          #5
          Re: setting a forms Field values in Xbasic

          e._set.reportfilename.value = e._currentRowDataNew.EMAIL+ " " + now()
          did you try, i tested that one earlier and it works as expected.
          on the debug what value you are getting for session.sentto.

          Your code will not work in xbasic syntax is
          var ="javascript here";
          so simply inserting this code will not work.
          that was in javascript, i could test it for you and report later. not in xbasic.
          thanks for reading

          gandhi

          version 11 3381 - 4096
          mysql backend
          http://www.alphawebprogramming.blogspot.com
          [email protected]
          Skype:[email protected]
          1 914 924 5171

          Comment


            #6
            Re: setting a forms Field values in Xbasic

            session variables don't they need server, is this published and tested in the published version?
            when you are assigning a value to a variable and the reference that variable, the quotes should not be there. as far as i know.
            thanks for reading

            gandhi

            version 11 3381 - 4096
            mysql backend
            http://www.alphawebprogramming.blogspot.com
            [email protected]
            Skype:[email protected]
            1 914 924 5171

            Comment


              #7
              Re: setting a forms Field values in Xbasic

              you are correct, javascript does not like dot notation, however
              I tested ajaxcall version and javascript version of assigning field value. they both work as expected.
              in ajaxcallback I used the same session variable as you did.
              if you like post back I will show in a screencast, if you like.
              thanks for reading

              gandhi

              version 11 3381 - 4096
              mysql backend
              http://www.alphawebprogramming.blogspot.com
              [email protected]
              Skype:[email protected]
              1 914 924 5171

              Comment


                #8
                Re: setting a forms Field values in Xbasic

                Ok,
                so lets keep on track. Remember I am trying to set the value of a field in a grid using xbasic.
                That is my dilemma.
                I am sending an email and adding an attachment. This is done via the xbasic sample mandrill code provided. I am able to send the email and of course with the attachment. The goal now is to set the value of a field to say that there was an email sent on this day and at this time, using Now()
                which by the way you were right, Date() was unnecessary and the date appeared twice in the debugger because of course Now() includes the date and time.
                NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                Comment


                  #9
                  Re: setting a forms Field values in Xbasic

                  Code:
                  dim vendor as c
                  	vendor = e._currentRowDataNew.vendor_name
                  	session.vendor = vendor
                  	session.email_sentto = session.vendor + " " + now()
                  	e._set.comment.value = session.email_sentto
                  this is what I used to test the code and it sets as expected.
                  thanks for reading

                  gandhi

                  version 11 3381 - 4096
                  mysql backend
                  http://www.alphawebprogramming.blogspot.com
                  [email protected]
                  Skype:[email protected]
                  1 914 924 5171

                  Comment


                    #10
                    Re: setting a forms Field values in Xbasic

                    http://screencast.com/t/VsQlmxBG85B3
                    take a look
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


                      #11
                      Re: setting a forms Field values in Xbasic

                      I notice that you DO NOT have a detail view, does this make a difference in anything. I am going to do a screencast myself because what I am doing with the same code does NOT work in my version of Alpha and I am stumped...
                      NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                      Comment


                        #12
                        Re: setting a forms Field values in Xbasic

                        it does not work in detail view.
                        e._set is converted to its javascript counterpart
                        {grid.object}.setValue('G',name.rownumber,value);
                        'G' and rownumber are not applicable in the detail view, the javascript does not know about the value.
                        it probably a bug I do not know. or they should not have copied the instruction from grid part to detail part without any modification.
                        thanks for reading

                        gandhi

                        version 11 3381 - 4096
                        mysql backend
                        http://www.alphawebprogramming.blogspot.com
                        [email protected]
                        Skype:[email protected]
                        1 914 924 5171

                        Comment


                          #13
                          Re: setting a forms Field values in Xbasic

                          however you could send javascript command to the browser as I detailed in post number 3 adjusting to detail view as the xbasic function return value.
                          thanks for reading

                          gandhi

                          version 11 3381 - 4096
                          mysql backend
                          http://www.alphawebprogramming.blogspot.com
                          [email protected]
                          Skype:[email protected]
                          1 914 924 5171

                          Comment


                            #14
                            Re: setting a forms Field values in Xbasic

                            Ok, so fifty tries later I FINALLY got what I wanted and it took some figuring...I will create a little jing video if anyone wants but the code that worked - well I couldnt do it in xbasic - which was my goal BUT this is how I did it.
                            The Goal is to send an email with an attachment and log when it was sent, allow for a custom message (using mandrill) with the sending email a variable - since I have users in a saas application that want to send out an invoice as a PDF.
                            This is a Grid with a detail view. I have unchecked close detail view on submit.

                            I have an action button that is going to "Email Invoice"
                            The action buttons first inline javascript is "Submit Detail View" I am doing that in case someone alters the email address to be sent to prior to clicking the button.
                            The second action is an ajaxcallback with compute current row checked.

                            Functionname:setmailto
                            Code:
                            function setmailto as c (e as p)
                            	
                            	session.mailedto = e._currentRowDataNew.EMAIL
                            	session.sentto = session.mailedto + " " + Date()
                            	session.mailfrom = e._currentRowDataNew.REPLYEMAIL
                            	session.mymsg = e._currentRowDataNew.CUSTOM_MESSAGE
                            	session.sentto = session.mailedto + " " + Now()	
                            
                            end function
                            The trick now is to NOT add a new action but rather add in javascript to execute after the function in the advanced area of the ajaxcallback!~
                            Thats what did the trick - anywhere else I kept getting errors.
                            I modified the code gandi provided in post 3 to read as follows

                            Code:
                            var email = {grid.object}.getValue('D','EMAIL');
                            var d1 = new Date();
                            d1 = d1.toFormat('MM/dd/yyyy 0h:0m:0s AM');
                            var emailSent = email+ " " + d1;
                            {grid.object}.setValue('D','REPORTFILENAME',emailSent);
                            {grid.Object}.submitDetailView();
                            ***The interesting part here is if you stick this exact same code in an inline javscript OnClick Event - even running synchronously - you will get the message to save first and the code errors out. So it must be put in the same ajaxcallback, in the advanced section to work out - at least for me.



                            Next is Open a Report, Label, or Letter layout and target to xbasic

                            Functionname: ReportForEmail

                            Code:
                            function ReportForEmail as c (e as p)
                            	
                            dim msg1 as c
                            dim key as c 
                            key = e.fileSessionKey
                            dim b as b 
                            'get the binary day for the report
                            session.GetDataFromFile(b,key)
                            dim size as n 
                            size = b.size()
                            if size = 0 then 
                            	msg1 = "alert('Report was not sent.');"
                            	exit function
                            end if 
                            'If you don't have a Mandrill secret key, sign up at Mandrill.com
                            dim mysecretkey as c = ""   'if you leave this blank the key value is read from a setting in Project Properties
                            dim ms as p
                            dim date as d
                            ms.send_to = session.mailedto
                            	if session.mailedto = "" then
                            		msg1 = "alert('Email Address is missing or invalid!');"
                            		exit function
                            	end if
                            ms.from_email = session.mailfrom
                            ms.subject = "Wildlife Control Invoice/Estimate"
                            ms.message_html = "Please find the attached invoice and or estimate." + "<br>" + session.mymsg + crlf()+\ 
                            "<br>""<br>""<br>""<center><b>Confidentiality Notice:</b> This e-mail message, including any attachments,is for the sole use of the intended recipients." + crlf()+\
                            "It may contain confidential and privileged information or may be otherwise protected by law." + crlf()+\
                            "Any unauthorized review, use, disclosure or distribution is prohibited." + crlf()+\
                            "If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message." + crlf()+\
                            "If you received this email by mistake, send complaints/concerns to [email protected]</a>This email is generated using NWCOPRO software.</center>" 
                            
                            dim ms.attachmentsArray[1] as p
                            ms.attachmentsArray[1].name = "Wildlife Control.pdf"   'if the report was an html report, use the .html extension
                            ms.attachmentsArray[1].type = resolve_mime_type("pdf") 'if the report was an html report, use the 'html'
                            ms.attachmentsArray[1].content = base64encode(b)
                            
                            dim pResult as p
                            pResult = email_send_mandrill(mysecretkey,ms)
                            if pResult.error = .f. then 
                            	msg1 = "alert('Your Invoice/Estimate was sent.');"
                            else
                            	__name = "alert('Your Invoice/Estimate was not sent.');"
                            end if
                            end function

                            And Finally, I have a submit and save action.
                            What this effectively does is what I wanted to accomplish in the first place.

                            I wanted to send an email and record in a field when it was sent and to whom.


                            Now, the only bugger here is that the msg1 alert DOES NOT fire at all.
                            So no message appears saying if the email was sent or NOT - even though it does work as expected otherwise.
                            if someone could help me troubleshoot that I would be very thankful!

                            I guess the "presult" isnt working or something and I am not sure how to catch that in the debugger...


                            I hope this help someone in the future!
                            Last edited by CharlesParker; 08-16-2015, 12:23 PM.
                            NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                            Comment


                              #15
                              Re: setting a forms Field values in Xbasic

                              Charles,
                              Following this, please if you have time cut the video, it helps to understand the code especially since you utilizing other services (mandrill).
                              Regards,

                              Kotin Karwak
                              Developer Edition
                              Version 12.3 Build 2684
                              System Addins: Build 4438
                              Build machine Windows Vista
                              Skype: mateso08

                              Comment

                              Working...
                              X