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

Creating a session variable inside a button click.

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

    Creating a session variable inside a button click.

    Hey guys,

    I want to know how to create a session variable that contains the value of a textbox I just entered.

    When I create a new record, it contains an "id", when I click save, I need to create a variable that I want to use to filter the next list that appears.

    Can I create a session variable inside a button click? Can the variable value be set to that of a textbox control?

    #2
    Re: Creating a session variable inside a button click.

    A button click fires a Javascript event, you can't create the Session variable there (you can read published Session variables, AFAIK you can't create or write to them). My first response is that you will need to fire an Ajax callback and set the Session variable on the server. You can send the value of the textbox control by appending it to the QueryString. I would suggest you set the "Click" event of the button to the Action javascript "create Ajax callback" action and look at the property sheet. Towards the bottom is a section on Additional data to send, it explains how you can send control values back. You get the value of the control in js with var _var1 = {dialog.Object}.getValue('myTextControl').

    I understand the above is terse, I don't know how much help you actually need. I'm sure others will respond with more precise help or, if not, post again and I'll work up detailed steps (use them at your own risk :) ).

    Comment


      #3
      Re: Creating a session variable inside a button click.

      Somewhere on this forum, I copied my live code on what I did to do an Ajax callback. If you want to see my example do a search.

      Comment


        #4
        Re: Creating a session variable inside a button click.

        Let's say your control is the ID field. And your callback is named "setVars". I'm also assuming you're using a UX. Syntax for a grid is a little different.

        The Xbasic here can be very simple:

        Code:
        function setVars as c (e as P)
           session.MyID = e.dataSubmitted.ID
        end function
        That's it!

        Keep in mind that the e.dataSubmitted is always character type, and that session variables are always character type.

        So when it comes time to consume this later on, you may need to get the numeric type with something like this:

        Code:
        n_ID = convert_type(session.MyID, "N")
        With all that said, I wonder if a callback is what you want or need. If you're Submitting a record, then you're already using the onDialogValidate. You can put the code right in there as well, simply as:

        Code:
        session.MyID = e.dataSubmitted.ID
        I'm keeping it simple here, could spend an hour on all sorts of related matters, but this may get you on your way.
        -Steve
        sigpic

        Comment


          #5
          Re: Creating a session variable inside a button click.

          Thanks for all the replies. I am going to try the advice you gave me and I will respond with results. Thanks.

          @Norman - I'm also not sure how much help I need. Pretty new to Alpha. But I'll go try again now and see how far I get.

          @Ken - Thanks, I'll see if I can find it.

          @Steve - Yes I'm using a UX, and also the id as a character type is fine.

          Comment


            #6
            Re: Creating a session variable inside a button click.

            Originally posted by Steve Workings View Post
            Let's say your control is the ID field. And your callback is named "setVars". I'm also assuming you're using a UX. Syntax for a grid is a little different.

            The Xbasic here can be very simple:

            Code:
            function setVars as c (e as P)
               session.MyID = e.dataSubmitted.ID
            end function
            That's it!
            So if I declare this in my Xbasic functions. Do I need to call the function in the Javascript attribute tab?

            For example currently it contains

            Code:
            {dialog.object}.saveListEdits('LIST_TESTING_PARENT',{rows: 'allRows'});
            {dialog.object}.runAction('Switch to add item to report screen');
            Do I need to add setVars(); or anything like that?

            Comment


              #7
              Re: Creating a session variable inside a button click.

              When I create a new record, it contains an "id", when I click save, I need to create a variable that I want to use to filter the next list that appears.
              ..
              @Steve - Yes I'm using a UX, and also the id as a character type is fine.
              so you are using dialog/ux to insert the new record. you should be then using the afterDialogvalidate event to savedataToFile(s) actionscripting.

              if the above statements are correct then,
              put your cursor over the action save data and right click then select the variables exposed by this action. you will see one of the variable is e.rtc.recordWasSaved which is either true or false.
              so immediately after the action add the following
              Code:
              if e.rtc.recordWasSaved then
              session.MyId = e.dataSubmitted.ID
              end if
              ps:i am writing without the developer. so make sure the nomenclature is correct.
              this will set the session variable to the data you have in your textbox.
              this is not in addition to the steve's code, he gave an example how to set the session id. the above will be in the dialog/ux without that code.
              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: Creating a session variable inside a button click.

                Originally posted by Steve Workings View Post
                Let's say your control is the ID field. And your callback is named "setVars". I'm also assuming you're using a UX. Syntax for a grid is a little different.

                The Xbasic here can be very simple:

                Code:
                function setVars as c (e as P)
                   session.MyID = e.dataSubmitted.ID
                end function
                That's it!

                Keep in mind that the e.dataSubmitted is always character type, and that session variables are always character type.

                So when it comes time to consume this later on, you may need to get the numeric type with something like this:

                Code:
                n_ID = convert_type(session.MyID, "N")
                With all that said, I wonder if a callback is what you want or need. If you're Submitting a record, then you're already using the onDialogValidate. You can put the code right in there as well, simply as:

                Code:
                session.MyID = e.dataSubmitted.ID
                I'm keeping it simple here, could spend an hour on all sorts of related matters, but this may get you on your way.
                Hi Steve,

                I have not been very successful.

                Please have a look at my screenshots

                In the onLogin UX component I declare the session variable.
                session variable declared.png

                -----
                In the UX component that is invoked by the onLogin, I have the control which contains the data that needs to go to the variable.
                origin id control.png

                -----
                In the click event of the Synchronize(renamed to Submit report) button I fill the variable with the data
                Setting the variable.png

                -----
                In the detail view of the child list, I want to fill a control with variable that was saved
                Setting variable as default.png

                ----
                I publish the project to local host, enter the value into the control and press the button.
                Entering ID into control.png

                -----
                When I then create a new record from the child list and the detail view opens, the control is supposed to be filled by the variable.

                INTERESTING OBSERVATION - When the detail form opens, the control that needs to be filled by the variable once flashes the "Some Default" value that I set for the session variable on login, and then it goes blank.

                Any advice would be appreciated. Thank you so much.

                Comment


                  #9
                  Re: Creating a session variable inside a button click.

                  Picture #3 is your problem. That dialog is for javascript. But you've also put Xbasic code there, and that won't work. So, take it out of there. Javascript on the client side, Xbasic on the Server side.

                  Now, Gandhi is always very helpful but he missed the fact that you're using a List control for the submit. This means you need a little different approach than what he describes.

                  One method might be to change what you're doing in Picture 3. Instead of inserting Xbasic, insert the javascript for a callback to your Xbasic function:

                  Code:
                  {dialog.object}.ajaxCallback('','','SetVars','','',{deviceOfflineFunction: function() {   }});
                  There are certainly other places and events where you could do this but this seems like an obvious & easy first choice.

                  There's a possibility that things won't work quite as you wish because of the timing. Javascript is asynchronous, and these and other client-side events happen more quickly than the time it takes to make a callback and establish that variable.

                  There are other avenues that don't require a session variable -- something like a state variable or other javascript variable can do the job. And, there are methods to help insure that the javascript fires in an order that makes sense. But start with this, see where it takes you. In the time it took me to write this we could definitely have come up with a solution even if we had to try three things.

                  - Steve
                  -Steve
                  sigpic

                  Comment


                    #10
                    Re: Creating a session variable inside a button click.

                    Originally posted by Steve Workings View Post
                    Picture #3 is your problem. That dialog is for javascript. But you've also put Xbasic code there, and that won't work. So, take it out of there. Javascript on the client side, Xbasic on the Server side.

                    Now, Gandhi is always very helpful but he missed the fact that you're using a List control for the submit. This means you need a little different approach than what he describes.

                    One method might be to change what you're doing in Picture 3. Instead of inserting Xbasic, insert the javascript for a callback to your Xbasic function:

                    Code:
                    {dialog.object}.ajaxCallback('','','SetVars','','',{deviceOfflineFunction: function() {   }});
                    There are certainly other places and events where you could do this but this seems like an obvious & easy first choice.

                    There's a possibility that things won't work quite as you wish because of the timing. Javascript is asynchronous, and these and other client-side events happen more quickly than the time it takes to make a callback and establish that variable.

                    There are other avenues that don't require a session variable -- something like a state variable or other javascript variable can do the job. And, there are methods to help insure that the javascript fires in an order that makes sense. But start with this, see where it takes you. In the time it took me to write this we could definitely have come up with a solution even if we had to try three things.

                    - Steve
                    Hi Steve,

                    I changed the code according to your instructions and it worked perfectly. The value is saved in the variable and when I enter the detail view screen for a new record in the child list it doesn't flash "Some Default" anymore, but the correct value.

                    Next step is to get it to stay, but I have a few ideas on fixing it. But it looks like my original problem was solved. Thank you so much.

                    Another question, how did you guys learn the basics of alpha, lots of experience and trial and error and watching videos? or maybe a course of something?

                    Comment

                    Working...
                    X