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

Simple Filter on user id

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

    Simple Filter on user id

    Much has already been written on this topic and I still don't get it. I want to set a filter based on the current userid. The index page is set to my login component. Is that a problem?


    First where does the code go? A post by "juliie" worked through all this but it seems a conclusion was never posted.

    And what is the code that identifies the current userid?


    Thanks...John

    #2
    Re: Simple Filter on user id

    Ok, this is what I do,
    Unsure if it's right but it works for me. :-)
    I send the user on succesful loggon to a page LoginBuffer.A5w
    that has this on it
    Code:
    <%A5
    Dim pUser as p 
    a5ws_logged_in_user_values(pUser,request,session) 
    if eval_valid("pUser.userid") = .T. then 
        Session.UserName = pUser.userid 
        Session.UserGuid = a5ws_get_guid_from_user(pUser.userid,request)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '''''Below is for my usage you won't need it
    	'Session.UserPrefArea = LookupC("F",Session.UserGuid,"Activearea","C:\\xxx\\xxxx","xxxxguid")
    	session.userUlink = a5ws_get_ulink_from_guid(Session.UserGuid)
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''	
    end if
    
    
    Response.Redirect("YourLoggedInPage.a5w")
    %>
    Now in all my User filters I create a similar named Arguement
    That arguement is :AGUID and it is loaded from the Session.UserGuid variable. I then filter all the recs against that Arguement

    The code above could be a lot tidier, but it works.
    -
    Remember though session Vars expire so you need to establish a handler for that (if you want)

    Comment


      #3
      Re: Simple Filter on user id

      ah ha... i will try this, but thank you so much!

      Comment


        #4
        Re: Simple Filter on user id

        For some reason, the session variable is not being captured.

        I placed save_to_file(session.UserName,"c:\test.txt") (as suggested in another post) and the test.txt file has a blank page.

        Here is the code in the login page (index.a5w)

        Is this "deleting the userid? This seems like it should be an easy task ... but I just don't get it. Thanks in advance for any help.


        +++++++++++++++++++++++++++++++++++++++++++++++++++++

        <%a5
        if eval_valid("submitbutton")
        if eval_valid("userid")
        dim session.__protected__userid as c
        session.__protected__userid = userid
        end if
        end if
        %>




        <html>
        <head>

        <%a5


        Delete tmpl_nav_main
        DIM tmpl_nav_main as P
        tmpl_nav_main = a5w_load_component("nav_main")
        'Following code allows you to override settings in the saved component, and specify the component alias (componentName property).
        'Tip: Keep the componentName property short because this name is used in page URLs, and it will help keep the URLs short.
        'Each component on a page must have a unique alias (componentName property).
        with tmpl_nav_main
        location = ""
        componentName = "nav_main"
        end with
        '=======================================compute the HTML for the Component=======================================
        delete x_nav_main
        dim x_nav_main as p
        x_nav_main = a5w_run_Component(tmpl_nav_main)
        ?x_nav_main.Output.Head.JavaScript
        ?x_nav_main.Output.Head.CSS_Link
        %>

        <%a5
        Delete tmpl_login
        DIM tmpl_login as P
        tmpl_login = a5w_load_component("login")
        'Following code allows you to override settings in the saved component, and specify the component alias (componentName property).
        'Tip: Keep the componentName property short because this name is used in page URLs, and it will help keep the URLs short.
        'Each component on a page must have a unique alias (componentName property).
        with tmpl_login
        componentName = "login"
        end with
        '=======================================compute the HTML for the Component=======================================
        delete x_login
        dim x_login as p
        x_login = a5w_run_Component(tmpl_login)
        '=============================================================================================================
        if x_login.RedirectURL <> "" then
        response.redirect(x_login.redirectURL)
        end
        end if
        ?x_login.Output.Head.JavaScript
        ?x_login.Output.Head.CSS_Link
        %>
        <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published -->
        <!--CSS for tmpl_login -->
        <link rel="stylesheet" type="text/css" href="file:///C:/Program Files (x86)/a5v9/css/BlueMoon/style.css">
        <!--Alpha Five Temporary Code End -->

        <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published -->
        <!--CSS for tmpl_nav_main -->
        <link rel="stylesheet" type="text/css" href="file:///C:/Program Files (x86)/a5v9/css/BlueMoon/components/a5navsysToolbar/style.css">
        <!--A

        Comment


          #5
          Re: Simple Filter on user id

          Its a mistake and unnecessary to send a user to a particular page after login. The way Alpha works, you have no guarantee they will pass through your 'buffer' page. If a user were to bookmark or just try to access a restricted page, which would send them to your login page, on login they would go back to that restricted page, bypassing your buffer page.

          John, the code you have on your login page came from one of my posts. That will capture the username, whatever they typed in to the username field on the login dialog. You've got it saving to session.__protected__userid, so why do you expect it to post something to a different variable named session.UserName?

          You might try testing with save_to_file(session.__protected__userid,c:\test.txt") in the right location.

          Its OK to filter by username, but not the best. Your users may want to change their usernames someday and then all your records will be orphaned.
          Steve Wood
          See my profile on IADN

          Comment


            #6
            Re: Simple Filter on user id

            Steve -- Thank you so very much. If you knew what a "fumbling hack" I am you wouldn't wonder why I would do or not do anything. I've been a member of this board since 2004 and I think I have attempted three answers. You'd think after five years the light would finally come on. :)

            Really appreciate all that you and the others folks on this board do to help people like me!

            With your suggestion I got it to work. Going to try and explain below what I did in case this might help others. I was confused by where to place the code.

            I placed the code below on the first line of the a5w (quotelist.a5w) page that I wanted to filter. Then created an argument by using the "Agrument dialog box" located in Web componenet associated with the corresponding a5w page.

            <%a5
            if eval_valid("submitbutton")
            if eval_valid("userid")
            dim session.__protected__userid as c
            session.__protected__userid = userid
            end if
            end if

            save_to_file(session.__protected__userid,"c:\test.txt")
            session.userid=session.__protected__userid
            %>

            I left your save_to_file code just incase i need it later.

            John

            Comment


              #7
              Re: Simple Filter on user id

              John - I wonder if you would be so kind as to explain a few more peripheral details as to how you got this working. (Or if anyone else could help me out.) I have been stuck the exact same problem for 3 days and I still can't get it to work.

              I have a login_component and a grid_component. The login_component is on the page login_page.a5w and the grid_component is on a page grid_page.a5w.

              I put the block of code that you suggested at the top of the grid_page.a5w and published it. I access the login_page.a5w in the browser and the login dialog comes up as it should and seems to work, however after submitting the login information, I get:

              500 Internal Server Error
              "Script Error
              Error:Script: /grid_page.a5w line:9
              save_to_file(session.__protected__userid,"c:\test.txt")
              Property not found
              session.__protected__userid subelement not found."

              It seems as though the session.__protected__userid variable is either not being set by the login component or is not available to the grid_page.a5w.

              For what it's worth, my grid is from a view that links 3 different tables. There is a field called "Owner" in the parent table of the view which I would like to filter on. If I hard code the filter in the grid (Owner="Scott") it works fine.

              My Web Security settings are such that:

              Redirect page - login = login_page.a5w
              Redirect page after login = grid_page.a5w
              (both of the suggestion of A5W help)

              Any ideas what I might be missing? (Forgive me if there's some critical piece of information missing or if I'm no explaining things properly. I've only installed A5 about 2 weeks ago.)

              Comment


                #8
                Re: Simple Filter on user id

                Scott -- I'll take a shot at explaining in detail and hope this helps. I apologize for the late response.

                1, My login component resides on my index.a5w page.
                The following code is on the first lines of the "source" tab in the index.a5w page.
                +++++++++++++++++++++++++++++++++++++++++++++++++++++++
                <%a5
                if eval_valid("submitbutton")
                if eval_valid("userid")
                dim session.__protected__userid as c
                session.__protected__userid = userid
                end if
                end if
                %>
                +++++++++++++++++++++++++++++++++++++++++++++++++++++++

                2. My login component is set to redirect to "quotelist.a5w" upon successful login. "Quotelist.a5w" has this code on the first lines of the "source" tab.

                +++++++++++++++++++++++++++++++++++++++++++++++++++++++
                <%a5
                if eval_valid("submitbutton")
                if eval_valid("userid")
                dim session.__protected__userid as c
                session.__protected__userid = userid
                end if
                end if

                save_to_file(session.__protected__userid,"c:\test.txt")
                session.userid=session.__protected__userid
                %>
                +++++++++++++++++++++++++++++++++++++++++++++++++++++++

                Probably some redundant code, but it works. It seems this code needs to be place on the first redirect page so that it initializes the session variable.

                I kept getting the error that you are getting until I put this on this page and included the "session.userid=session._protected_userid.

                Save_to_file(session._protected_userid,"c:\test.txt") is really helpful. If you can get the variable to pass to the text file you've almost got it.

                3. The third step is setting up the argument in the webcomponenet and the filter. Let me know if you need any help on that part of the puzzle.

                I also had a heck of a time getting my report dialog to filter on the session variable. It is probably the wrong way to do it, but I used Steve Wood's trick
                of saving the variable to the text file and used it in a filter: something like...

                if(get_from_file("c:\test.txt")="fritz123".OR.get_from_file("c:\test.txt")="cecilia123",agency="AgentOne",agency="AgentTwo"). I can see the obvious problems with this but for a short term solution it is working form me.

                I hope this is helpful. It would be my first attempt at helping someone actually achieve something on this board. And I owe this message board members a lot of favors!

                Good Luck...John

                Comment


                  #9
                  Re: Simple Filter on user id

                  SWEEEEEEEET!!!

                  Pat yourself on th back, John. I got it!!!

                  I was missing the code on the login.a5w page. Obviously that's needed to set the session variable. It seems so simple now that I see it but for four days I was stuck.

                  I got the filter working as well using your and Steve's suggestion. Because the field on which I want to filter (the 'owner' field in my grid) matches the userID, I can simply use:

                  owner=get_from_file("c:\test.txt")

                  in the filter option on the grid_component. Didn't need to create an arguement. So far, it seems to be working like a charm.

                  I understand the pitfalls of all of this, however this is (or will be) a simple 12-user system for my fantasy baseball league so I think this will work.

                  A million THANK YOUs!!!!!! Ditto to Steve - your input was valueable in getting me as far as I was.

                  Maybe I'll run into you guys again when I hit my next stumbling block. Take care.

                  Scott

                  Comment

                  Working...
                  X