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 e.newValues with protected session variables

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

    Setting e.newValues with protected session variables

    I know this should be very simple setting a field with a new value using OnInitialValueCalculate Event.

    No problems using static values but I can't for the life of me figure how to give a field the value of a session.__protected__variable.

    For static values you simply use:
    e.newValues.fullname="some name"

    so what I can't get is something like:
    e.newValues.fullname=session.__protected__fullname

    I have tried many combinations of "", s_quote, quote, '',etc.

    What am I doing wrong? Thank you!!

    #2
    Re: Setting e.newValues with protected session variables

    I just did this on an A5W page, and got the desired results:

    Code:
    <%A5
    dim session.__protected__fullname as c = "Michael"
    ?"session.__protected__fullname = " + session.__protected__fullname + "<br>"
    
    dim e as p
    e.newValues.fullname = session.__protected__fullname 
    ?"e.newValues.fullname = " + e.newValues.fullname + "<br>"
    %>
    It returned this:

    session.__protected__fullname = Michael
    e.newValues.fullname = Michael
    -Steve
    sigpic

    Comment


      #3
      Re: Setting e.newValues with protected session variables

      Steve,

      If I declare the variable within the OnInitialValueCalculate then yes I can get the variable to show on the grid field as desired as you described.

      However, for some reason this event (as well as the OnGridInitialize event) is not seeing my protected session variables or I am not declaring them properly for the event.

      What is interesting is that the a5w page that holds this test grid has a debug area that does correctly display all my protected session variables. So it appears to be an issue with these events not seeing these variables as "I would expect" them to.

      Any ideas how I can get these grid events to see these variables?

      Comment


        #4
        Re: Setting e.newValues with protected session variables

        Micahel,

        Try e.newValues.fullname=e.rv.session.__protected__fullname

        Notes from the OnPageRedirect event ...

        'e.rv - Request Variables (allows you to get at page variables and session variables
        'e.rv.Session - session variables.

        I am using this syntax to set a session variable named uuid from a grid value named uuid in the OnPageRedirect event ...

        e.rv.session="uuid" 'create session variable
        e.rv.session.uuid=e.rv.v.r_1.uuid 'set session variable
        Bob Moore


        Comment


          #5
          Re: Setting e.newValues with protected session variables

          Bob,

          That is the ticket!

          V10 has a lot of new things to learn but so far it has been worth it!

          Thanks again.

          Mike

          Comment


            #6
            Re: Setting e.newValues with protected session variables

            Great ...

            I just remembered another tip based on my example of setting a session variable above.

            If you are inserting a new record and haven't committed it yet, the row values are referenced with _r as in my example,

            e.rv.session="uuid" 'create session variable
            e.rv.session.uuid=e.rv.v.r_1.uuid 'set session variable

            Apparently V10 adds the _ to the rows of a new record.
            When I looked at this variable in Firebug, I could swear it reported a - and not a _. That threw me for a loop.
            Bob Moore


            Comment


              #7
              Re: Setting e.newValues with protected session variables

              OK, you would think that if I could follow your example of the OnGridInitialize to set a newValue of my V10 grid with a session protected variable, it would stand to reason that I could figure out how to set a value of an (hidden) up-datable field to equal the protected session variable on either the NEW AfterUpdateRecord event or the old reliable AfterUpdateRecords event, which worked in V9 with a simple:
              Code:
              DataSubmitted.Changed_By = session.__protected__fullname
              Now I have tried a lot of variations things like:
              Code:
              e.DataSubmitted.Changed_By=e.rv.session.__protected__fullname
              but no go.

              Any suggestions?

              Thanks!

              Comment


                #8
                Re: Setting e.newValues with protected session variables

                In V10, a lot of the events use the following format,as in the OnPageRedirect event

                function OnPageRedirect as v (e as p)
                '*******************************************************************************************************************
                'IMPORTANT: This event will only fire if the 'Target Page' property in the 'Update Settings' pane is set to: <Event>
                '*******************************************************************************************************************
                'This event must set the e.URL property.
                'This is the target URL to which the browser will redirect.
                'e.rv - Request Variables (allows you to get at page variables and session variables - e.g. e.rv.var1, e.rv.session.sessionvar1)
                ' as well as all data that was submitted to the server.
                'e.rv.Session - session variables. TIP: To set a session variable: e.rv.Session = "myNewSessionVariable"
                'Examples:
                'e.url = "page1.a5w" 'redirect to another page in your application
                'e.url = "http://www.google.com" 'redirect to google.

                'To pass data to the target page. (e.g. the 'Firstname' and 'Lastname' variables that the user entered in Row 1 of the Grid)
                'e.url = "page1.a5w?firstname=" + e.rv.v.r1.firstname + "&lastname=" + e.rv.v.r2.lastname
                e.rv.session="contact_id" ' create session variable to filter report
                e.rv.session.contact_id=e.rv.v.r1.id ' set session variable to contact id
                e.url="report1.a5w"
                end function

                My code snippet,in red above, creates a session variable and then sets the session variable to a field in the grid. Notice how I reference the value for the field "id" in the above example in bold red. You must use this new format to reference your fields with this function.

                As I mentioned in my previous post, it seems that if the record is new and has not been committed that the row reference values use an underscore as in r_1 as opposed to r1 so be careful here.

                You can use Firebug to check these references.

                Some also use the following format, as in the AfterUpdateRecords event which use the same format you are used to in V9

                function AfterUpdateRecords as v (Args as P, PageVariables as P)
                with PageVariables
                end with
                end function
                Bob Moore


                Comment


                  #9
                  Re: Setting e.newValues with protected session variables

                  I know this topic is quite old, but I found it useful for something I was trying to do. I was running into a problem where if all my code was in my A5W page it worked fine, but if I moved some to an AEX file, it did not.

                  I have an Xbasic function in an AEX file that was setting some session variables and I was running into the problem with the following code.

                  SomePage.a5w:
                  Code:
                  [COLOR="#0000FF"]<%a5[/COLOR]
                  [COLOR="#800080"]' Load AEX file then call the function in MyAEXFile to set session.__protected__someVar[/COLOR]
                  [COLOR="#008000"]a5w_load_aex([/COLOR]"MyAEXFile.aex"[COLOR="#008000"])  [/COLOR]                                                              
                  [COLOR="#008000"]SampleFunction([/COLOR]"doggy"[COLOR="#008000"])[/COLOR]                                                                     
                  [COLOR="#800080"]' Check if the session variable exists and print an appropriate message[/COLOR]
                  if ([COLOR="#008000"]eval_valid([/COLOR][COLOR="#808080"]"session.__protected__someVar"[/COLOR][COLOR="#008000"])[/COLOR]) then
                  	?[COLOR="#808080"]"session.__protected__someVar = " [/COLOR]+ session.__protected__someVar
                  	delete session.__protected__someVar
                  else
                  	?[COLOR="#808080"]"someVar undefined."[/COLOR]
                  end if
                  [COLOR="#0000FF"]%>[/COLOR]
                  BROKEN SampleFunction:
                  Code:
                  FUNCTION SampleFunction AS C (someValue as C)
                  	delete session.__protected__someVar                ' Delete the variable if it exists.
                  	dim session.__protected__someVar as C = someValue  ' Set the variable.
                  END FUNCTION


                  Using the guidelines here, I changed my function to the following and it works great.

                  Working SampleFunction:
                  Code:
                  FUNCTION SampleFunction AS C (someValue as C)
                  	delete session.__protected__someVar       ' Delete the variable if it exists.
                  	session = "__protected__someVar"          ' Create the variable.
                  	session.__protected__someVar = someValue  ' Set the variable.
                  END FUNCTION


                  So what I take away from this is that declaring/setting a session variable in an AEX file may not work in the same way as you can set it on an a5w page. Admittedly, the correct way to do it is probably the way that works on both. My point is that with this thread, I was able to learn how to do it and thought I'd pass on what I learned so someone else might learn faster.

                  Comment

                  Working...
                  X