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

Session variable not available in field's validation xbasic

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

    Session variable not available in field's validation xbasic

    Here is the grid scenario:

    OnGridInitialize event set a session variable: e.rv.session.test = "abc"

    In a field's "validation xbasic" function put: debug(1)

    In working preview insert or modify and submit a record, and examine the contents of the e object. There is no session.test variable available.

    Why?
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    Re: Session variable not available in field's validation xbasic

    Peter,
    I tried your example, and put this in the validation Xbasic:
    function validate_FIRSTNAME as p (e as p)
    'Sample validation function.
    'Data for the current row is available in 'e.data'. For example, e.data.firstname, e.data.lastname
    if e.data.FIRSTNAME = "bill" then
    validate_FIRSTNAME.hasError = .t.
    validate_FIRSTNAME.errorText = "FIRSTNAME cannot be Bill."+e.rv.session.test


    end if
    end function
    And it worked. The error message said:
    FIRSTNAME cannot be Bill."abc
    You are correct about it not showing up in the Debugger.
    Jay
    Jay Talbott
    Lexington, KY

    Comment


      #3
      Re: Session variable not available in field's validation xbasic

      Hhmmm...you're right it does work. It's just that you can't see the session var in the debugger. Well that's a fine how to do. Thanks Jay!
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        Re: Session variable not available in field's validation xbasic

        Taking this a setup further, I found this only works if you declare the session variable from within the same component, as in the earlier examples that are using the OnGridInitialize event.

        While this does work, it doesn't fit the needs of most applications or the intended value of session variables in being able to declare them once and then share them across grids. In most cases, we/I want to be able to use a session variable that has been declared elsewhere in my application and reference it again and again on other grids/pages. I cannot find a way to use a session variable declared in a different component and make it work in the Xbasic Validation function.

        The only work around I can make work is to declare the original session variable into a new session variable from the OnGridInitialize event and then use the new session variable in the Xbasic Validation, but you cannot use the original session variable.

        I proved this to myself by first setting up a grid using the example above and it worked as prescribed. But I need to use a session variable that is declared in a different component, and when I changed this example to use that variable, it fails. I found if I set the original session variable to a different name in the OnGridInitialize event, I can then use that 2nd copy of the session variable in the Xbasic Validation function

        Iv'e been struggling with this for a while and really appreciate Peter and Jay looking into this. I never would have thought to declare a 2nd named copy of a session variable to make it available in the Xbasic Validation function. This seems to be an oddity to me that really tripped me up until todays lightbulbs went off thanks to Peter and Jay

        To recap, this is what I found to get a "real life" session variable to work with the Xbasic Validation feature
        1) Working Preview will not work if there are any session variables referenced in the Xbasic Validation feature
        2) If you need to reference a session variable that was declared in a different component/grid event, you need to
        a.) declare a 2nd copy of the session variable in the grid your working with (OnGridIntialize is a good place)
        b.) use the 2nd copy of the session variable in the Xbasic Validation code

        Comment


          #5
          Re: Session variable not available in field's validation xbasic

          Peter, I'm glad your post generated some discussion. I posted similar question last Friday, but had no replies.

          To All,
          Here is something that might be of interest:
          In Working Preview mode try using OnGridExecute event instead of OnGridInitialize. And include the "shared" and "default" attributes on the "dim" statement and drop the "e.rv" when using Working Preview mode:
          function OnGridExecute as v (e as p)
          dim shared session.test as C = default ""
          end function

          My gird is not editable. So for my test, I placed a button on the grid with an ajax callback to a function coded as:

          function dbgShowVar as c (e as p)
          dbgShowVar = "alert('You submitted a value of: " + js_escape(e._currentRowDataNew.dsSetName) + "---" + session.test + "');"
          session.test = session.test + ", ABC"
          end function


          I appended another ", ABC" to the session var at the end of the function to prove the session var hangs around between callbacks instead of getting lost.

          The above does not work when running the app for real as the "e.rv.session" and "e.session" vars are expected to be used in that case as answered in the thread.

          I still find it hard to believe there is not more discussion here on how to get a solution that works for both web mode and Working Preview mode.

          I am going to try a temporary pointer and setting it to either "e.rv.session / e.session" or "session" and using the WITH / END WITH structure to get the code to work. I just need a reliable way to know which mode the app is running in. Also, depending on how the session variable is to be used, it can be useful to put something like "delete e.rv.session.test" in the OnGridInitialize. It deletes any existing var of that name when running in web mode and is benign in Working Preview mode.

          Does Alpha Five Version 11 fix this discrepancy in coding between real web and Working Preview mode?

          - Rich Fulham

          Comment


            #6
            Re: Session variable not available in field's validation xbasic

            Actually this does work, you just have to run it in localhost. You won't get the results in live preview because session vars aren't shared. I just did an experiment using Alpha Sports where I set a session var in an a5w page, and then ran a grid with xbasic validation which properly trapped the session var.
            Peter
            AlphaBase Solutions, LLC

            [email protected]
            https://www.alphabasesolutions.com


            Comment


              #7
              Re: Session variable not available in field's validation xbasic

              Peter, I found the same results you're sharing - it works when published to my local host and also my production VPS (at godaddy).
              Question, when you say "set a session var in an a5w page"... is that the same page the grid is inserted?

              BTW - I also used Firebug and couldn't see the session variables much the same as seen (rather not seen) when using debug(1)

              Thanks, Dave

              Comment


                #8
                Re: Session variable not available in field's validation xbasic

                Originally posted by ids-dave View Post
                Question, when you say "set a session var in an a5w page"... is that the same page the grid is inserted?
                No. Different page.
                Peter
                AlphaBase Solutions, LLC

                [email protected]
                https://www.alphabasesolutions.com


                Comment


                  #9
                  Re: Session variable not available in field's validation xbasic

                  Peter
                  Okay - I opened mouth and inserted foot (with a little kick for good measure)

                  I went back to the grid in question and changed my session variables back to their original values and everything works just as you all have pointed out. My grid is dealing with dates, times and elapsed hours/minutes and I'm thinking I got myself twisted up when debug would not show the e.session objects

                  Many apologies for my erroneous addition to the originally posted issue

                  The original problem with debug that Peter posted and Jay confirmed is still a problem (in my case anyway). Dates and time fields are intensive in my app and it would be so much better if I could use debug to inspect some of these values more closely. I understand you can show the data in an alert message, but in some cases I need the field type information that is accessible via debug and Firebug

                  Thanks, Dave

                  Comment


                    #10
                    Re: Session variable not available in field's validation xbasic

                    My version of code works in Working Preview mode, just not in real mode! If the running mode could be determined then perhaps use an "IF" statement to run one method or the other? Anyone know if Version 11 has this same problem?



                    function OnGridExecute as v (e as p)
                    dim shared session.test as C = default ""
                    end function


                    function dbgShowVar as c (e as p)
                    dbgShowVar = "alert('You submitted a value of: " + js_escape(e._currentRowDataNew.dsSetName) + "---" + session.test + "');"
                    session.test = session.test + ", ABC"
                    end function



                    Note: For Working Preview mode (coded above) I dropped the "e." pointer variable and used "SHARED" and "DEFAULT" on the DIM statement and I moved the init code to OnGridExecute.

                    -Rich Fulham

                    Comment

                    Working...
                    X