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

Filtering on logged in user in a mobile persistent login app

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

    Filtering on logged in user in a mobile persistent login app

    Hey guys,

    So I've realized getcurrentuser and session variables doesnt work as well in persistent login situations.

    But I need to filter the list for the logged in user, and trying to get my head around this now.

    So as far as I've gathered
    When you save the token to local storage you need to store the username
    like: e._state.userName = userName (in XBasic) AND localStorage.setItem('userName',userName); (in JavaScript)
    When you open the embedded UX you need to retrieve it and pass it into a variable, from witch you'll create the argument for the list filter.
    like: var userName = pObj.stateInfo['userName']; ----- But I don't see something like localstorage.getItem ever be used?

    And when I get it again in which event should I declare the variable in order for the list to be able to use it as an argument?

    This is extremely confusing.

    #2
    Re: Filtering on logged in user in a mobile persistent login app

    I see no issue using A5WS_GetCurrentUser()... although I would use the current Context.Security functions instead. The sample template for persistent login uses Context.Security.

    You should never use Session variables in a mobile app... regardless of the situation. Again, the sample template for persistent login does not use session vars... makes use of state vars... and sets and gets localstorage items.

    Work backward from what you want to do. You're working with a List. You need an argument filter. In mobile there are really only 2 ways to provide a filter argument with data:

    1. A Session var - which should never be used in a mobile app - so that's out.
    2. Set value at Runtime - pointing the argument to a control to get its data... this is what you want to do.

    So... if you're going to use, for example, a Textbox Control for the value of an argument... then you must first set the value of that Textbox control.

    At whatever point you validate your Username, e.g. after a successful login, set the value of that Textbox Control. Now you can use that Textbox control for the argument value. At that same point, save that Username for future use... e.g.:

    a State var
    localstorage
    Phonegapfile strorage
    Last edited by Davidk; 02-09-2018, 12:37 PM.

    Comment


      #3
      Re: Filtering on logged in user in a mobile persistent login app

      Since I u session vars in my mobile PGB application, I was wondering what are the pitfalls that make it a really bad choice? I believe you, but would like some pointers. Currently all UX components set the companyid with a lookup using the getuser method you listed but not using “context” as suggested.
      It seems to be working but it seems it might be a bad choice for future proofing.

      Your thoughts would be most appreciated.
      NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

      Comment


        #4
        Re: Filtering on logged in user in a mobile persistent login app

        If the server isn't there... your session var isn't there. Session vars expire.

        Comment


          #5
          Re: Filtering on logged in user in a mobile persistent login app

          Ok, but if the alpha server isn't there then there is literally no reason to use my application as it would be impossible to use in my case. Even though I do use pre-rendered UX's and restore from local storage (sometimes) if the session var is not there during a submit or a component load, the submit will fail and the user gets logged out.

          I only use 1 session var and that's to get the company_id of the logged in user during component load - beyond that I use arguments.

          I do not plan on a disconnected application at this time.
          Thanks for answering, btw.
          I think we have had this same conversation in the past in another thread so I don't expect a reply here unless you feel the need to expand on something.
          NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

          Comment


            #6
            Re: Filtering on logged in user in a mobile persistent login app

            Hey guys,

            I've been working of a previous post of David's.

            I am using the persistent template, I just want to set the value of a control in the child UX first before I'll go on to add it to a argument, and edited the following:

            IN PARENT UX: Replaced end of xbLogin with:

            Code:
            jsOut = "completePersistLogin();"
            xbLogin = jsOut
            e._state.token = token
            e._state.userName = userName
            e._state.guid = e.tmpl.guid
            IN PARENT UX: Added JavaScript

            Code:
            function completePersistLogin(){
            
            	var guid = {dialog.object}.stateInfo['guid'];
            	var userName = {dialog.object}.stateInfo['userName'];
            	var token = {dialog.object}.stateInfo['token'];
            	
            	{dialog.object}.panelSetActive('PANEL_APPLICATION');
            	localStorage.setItem(guid,token);
            	localStorage.setItem('userName',userName);
            	
            	//embedded child UX
            	var cObj = {dialog.Object}.getChildObject('EventsUX');
            	var cEle = cObj.getPointer('LOGGED_IN_AS');
            	cEle.innerHTML = userName;	
            	
            	var ele = {dialog.object}.getPointer('LOGIN_ERRORS');
            	ele.innerHTML = '';
            	
            }
            IN PARENT UX: In onRenderComplete

            Code:
            {dialog.object}.stateInfo['userName'] = userName;
            note: I keep thinking there should be something like this in there? var userName = localStorage.getItem(userName);

            After this thread's com

            IN CHILD UX: In onRenderComplete

            Code:
            var pObj = {dialog.Object}.getParentObject();
            if(pObj){
            	var userName = pObj.stateInfo['userName'];
            	var ele = {dialog.Object}.getPointer('logged_in_as');
            	ele.innerHTML = userName;
            }
            I'm not sure why this step is necessary because it looks like the value should already be set in the function completePersistLogin()

            Ok, so after this it does change the text in the child control. But changes it to 'undefined'. So it gets the userName variable, but it doesn't have a value.

            Comment


              #7
              Re: Filtering on logged in user in a mobile persistent login app

              onRenderComplete has finished running by the time completePersistLogin() is run.

              So... yes... you'll need that code to get your userName from localStorage... for the Parent to be setup up properly.

              For the Child UX, it depends on how it's set up to run. Is the Child UX onRenderComplete running while the Parent is finishing? Shove a console log or alert statement in both the Parent and Child UX to see in what order things are happening.

              Comment

              Working...
              X