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

Can't get session variable to increment

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

    Can't get session variable to increment

    I have a need to get a session variable to auto-increment each time a grid is submitted, and then have that value set as the default value of a specific field.
    I can get the initial record value set correctly, but subsequent records in the grid will not auto-increment.
    I have to "roll-my-own" auto-increment for specific reasons, and I am getting the starting value from a value in a table. When the record is saved, the next value is written back to the table, and that does work. If I open and close the grid (or re-load the web page), the session variable re-populates from the table, but if I create a new record immediately after creating a record, the session variable will not update the value for the new record. The issue I cannot achieve is to get the session variable to increment immediately and place the new value into the field when another value is a new record is created.

    I have tried the following code on the CanInsertRecord event on the grid:
    function CanInsertRecord as v (DataSubmitted as P, Args as p, PageVariables as p, Result as p)
    with PageVariables
    Result.Cancel = .f.
    Result.ErrorHTML = ""
    end with

    dim t as p
    dim session.next_number as c

    t = table.open("seq_cit_no")
    t.fetch_first()
    t.change_begin()
    vc_next_number = increment_value(t.Next_number)
    t.Next_number= vc_next_number
    t.change_end()
    t.close()

    delete session.next_number
    end function
    As you can see, I tried deleting the variable and then I re-create it on the OnGridInitialize event.

    Any thoughts?
    Jay Talbott
    Lexington, KY


    #2
    Re: Can't get session variable to increment

    Just as an update, I have tried many of the server site events, but still cannot get this to work.
    Any help would be appreciated.
    Thanks.
    Jay
    Jay Talbott
    Lexington, KY

    Comment


      #3
      Re: Can't get session variable to increment

      Jay -

      I see that you're dimming session.next_number in your code.

      But I don't see it in play below that -- you're making references to vc_next_number but never assigning one variable's value to another.

      Wouldn't you need something like:

      session.next_number = vc_next_number and then, of course, not delete session.next_number ?
      -Steve
      sigpic

      Comment


        #4
        Re: Can't get session variable to increment

        Thanks for responding, Steve.

        I have gotten this so messed up by trying so many different ways, that I should probably just delete all of the event scripts and start over.
        Essentially what I am trying to do is allow different users to each have their own auto-increment series. I am doing that by storing a value in a table in a record which has the "next value" and the user id. I don't have a problem when a user opens the grid, creates a record, and closes the grid. The "next value" in the table is updated properly, and when the grid is re-opened, the appropriate "next value" goes into the record.

        The problem occurs when a user puts multiple records in the grid at once. The "next value" is getting written to the table, but is not appearing in the grid. The grid retains the original value, but does not increment. I thought it would be easy to advance the session.next_number but it is not incrementing.

        I have the "Initial Value" field in the grid set to session.next_number, which works well the first time, but does not advance for the second and subsequent records.

        I guess I am confused about which event to use and what xbasic to use to get the session.next_number to increment so that the value on the grid will be correct.

        Thanks for the help.
        Jay
        Jay Talbott
        Lexington, KY

        Comment


          #5
          Re: Can't get session variable to increment

          I haven't tried your code, but two things:

          1. I think you inserted your code in the wrong place it needs to before the end with.

          2. Try assigning session.next_number = vc_next_number at the end rather than deleting the session variable.
          -Steve
          sigpic

          Comment


            #6
            Re: Can't get session variable to increment

            Steve,
            Thanks. I tried both of your suggestions, but while using the debug during the Working Preview, the session variable seems to disappear after each of the events. Because the a5w page is static, when I put the variable to display on the page, it stays constant, which does not surprise me. But when I hit the submit button, I see the value in the underlying table changes, but as the new record appears, the value in the grid is not updated

            This is on the OnGridInitialize event:
            function OnGridInitialize as v (e as p)
            dim t as p
            dim e.rv.session.next_number as c
            t = table.open("seq_cit_no")
            t.fetch_first()
            e.rv.session.next_number = t.Next_number
            'e.newValues.citationno = t.next_number
            t.close()
            end function
            This is on the CanInsertRecord event:
            function CanInsertRecord as v (DataSubmitted as P, Args as p, PageVariables as p, Result as p)
            with PageVariables
            Result.Cancel = .f.
            Result.ErrorHTML = ""

            dim t as p
            dim session.next_number as c

            t = table.open("seq_cit_no")
            t.fetch_first()
            t.change_begin()
            vc_next_number = increment_value(t.Next_number)
            t.Next_number= vc_next_number
            t.change_end()
            t.close()

            end with
            end function
            And I have the Initial value of the field in question set as session.next_number

            What the heck am I doing wrong?
            Thanks.
            Jay
            Jay Talbott
            Lexington, KY

            Comment


              #7
              Re: Can't get session variable to increment

              Jay-

              Does anyone know what the A5 page life cycle is? That determines a lot about this whole situation is going and could help you out. In ASP the postback changes are not always rendered until the next postback if there is one because the values are not always being set correctly.

              So this might seem like a dumb question but is this Grid being Reinitialized everytime the page loads during the init sequence of the page load? I couldn't imagine that you would be able to set session variables if there were being re-dimmed on every page load.

              Comment


                #8
                Re: Can't get session variable to increment

                Jay -

                After processing some debug(1) statements, the session variable persist through the initial page load. The page life cycle starts out with an OnGridExecute event before the OnGridInitialize event. So when the page is initially loaded the session variable is loaded, but as soon as you fire off an event OnGridExecute is called again.

                For whatever reason the Session variable that you initialize in the OnGridInitialize event is not being persisted to the next postback.

                The weird part is that if you change the text in a field on the grid a new callback is fired off. Which means that it is automatically firing off an OnTextChanged event to change the grid looks with the submit button and save buttons being activated. The OnTextChanged event does not get fired off for new record rows.

                When you figure out the solution I would like to know to see how A5 is handling there page cycle.

                Comment

                Working...
                X