How to pass along database and input values?

Hi, I have a collection (Call it "C"), and the standard user collection. So on the login page (using the register/login sample tutorial), I would like to be able to save the username for use on another page's query. For example, log in Joe, and then on the next page, display all records in C where UserID==Joe.

I have tried to map the username to a local storage variable ("Userid") on the login start page. It maps (arrow goes to the local var), but I don't ever get a value. I have an event on the next page for Load event:

var str = localStorage.getItem('Userid');
alert(str);

and it shows null.

If you are kind enough to show me how to get the value, then would I be able to use the same idea for my query? I'd like the query to be where UserID: . (UserID is a column in the collection).

thanks, and please answer in newbie terms, this is all new to me as an old fashioned C++ guy :-)
1 person has
this question
+1
This topic is no longer open for comments or replies.
  • Hi Ed,

    Your code to get LSV value looks ok.

    So i guess the problem is in the set LSV processing.

    Thus please specify how do you do it. Screen shots will help.

    Also try to invoke following code to store LSV on success event for login service.



    //Note: you should replace "yourLoginInputName" with your login input name value.
    var login = Apperyio("yourLoginInputName");

    //Store recieved value in the LSV.
    localStorage.setItem("Userid", login);



    Regards.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Thanks, that's better, but not quite what I want - now the alert shows [object Object]. I want to get the text string that is the username that was entered on the login screen.

    I plan to use that in database queries like where UserID: localStorage.GetItem("UserID"). Obviously I need some other function to extract the string. I am pretty familiar with sql queries and plan to use query services.

    So I would like to enter JavaScript into the request where field:

    return '{"UserID":"'+value+'"}';

    (from your build a search app tutorial)
    but not sure what +value+ should be to get the user id string from the local storage.

    Unless you have a better way? I am all ears :-)
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • OK, further, I did this (for other's reference)
    login page on success:

    var login = Appery('existinguser');
    //Store recieved value in the LSV.
    localStorage.setItem("Userid", login.val());
    var str = localStorage.getItem("Userid"); //use this anywhere in app to get username

    Ok, but now to the database query: I dont know what to map to where field? Localstorage variable Userid or ? ANd then what for the java script so I can do like I asked above?
    thx
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Hi Ed,

    Please follow these steps:

    1 Open your service mapping.

    2 Add "Userid" LSV to your mapping with following way: http://prntscr.com/41gpkp/direct

    3 You will get this "Userid" LSV in the bottom of right side panel. http://prntscr.com/41gq1a/direct

    4 Make link from just created "Userid" LSV to request field you need. http://prntscr.com/41gqby/direct

    That's all.

    Regards.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated