Alpha Video Training
Results 1 to 4 of 4

Thread: Session Variables as Date values in Array? Access Session Variable from Javascript ?

  1. #1
    Member
    Real Name
    Kim Gillan
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    106

    Default Session Variables as Date values in Array? Access Session Variable from Javascript ?

    I spent the better part of the day yesterday searching the Forum and help files for answers and never really came across anything that resolved my problem.
    This should be such a simple thing, Maybe I'm just going about it all wrong.

    [useing V11 Application Server]
    What I need to do is read field values (dates - 30 of them) from one single indexed record in an External table.
    These values then become column Labels as well as input values for multiple records in the current grid / table.

    I thought I could Publish a Session Variable, then use it as an array to load the values into,
    and by using a Session Variable I could access those values in javascript to set the column labels.

    Can Session Variables be used as Arrays? If so, how?
    I have tried multiple different ways and always come up with errors.
    I also tried this : <array>.INITIALIZE_FROM_TABLE(tbl) and could not get it to work with Session variables (actually, I couldn't get it to work at all)
    If anyone has some sample code they could share for a "visual" that would be great.

    I read that with V11 Session Variables must be strings.
    The field values I need to read into Session Variables are Dates, and need to be stored as Dates.
    Can a Session Variable be used as a Date field?

    As stated above, I want to use these external values as Dynamic Column Labels.
    I'm familiar with the [window ] $('fullname').innerHTML= fullname; combined with <div id=.... > method to create dynamic column headers,
    But my problem is passing the variable to the javascript.

    I Published SESSION.WHATOFFICETERM in Grid Properties, then in onGridRender :

    var myvar={grid.Object}.getSessionVariable('WHATOFFICETERM');

    myvar returns "undefined" everytime, even if I set SESSION.WHATOFFICETERM = "test" in OnGridExecute (ie, just trying to force this to work)

    does anyone have any suggestions as to why the getSessionVariable may not be working?

    Thank you in advance,
    Kim

  2. #2
    Member cgorman426@gmail.com's Avatar
    Real Name
    Colin Gorman
    Join Date
    Oct 2012
    Location
    Freehold, New Jersey
    Posts
    20

    Default Re: Session Variables as Date values in Array? Access Session Variable from Javascri

    Kim,
    Since you have the session variable and want them as column Labels after you publish the session variable in the grid properties then in the field label stick this <%A5 ?SESSION.WHATOFFICETERM%>.
    This might work for you let me know if there are any other variables I am unaware of or did not address.
    Colin

  3. #3
    Member
    Real Name
    Kim Gillan
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    106

    Default Re: Session Variables as Date values in Array? Access Session Variable from Javascri

    Thank you Colin!! Your suggestion for the label was a real time saver and much easier than my previous methods!

    I was able to take that a step further and break my "date" field down into mo-dd<br>year -- which displays very nicely.
    [since I'm using the date for the column header -- and have a record with 24 date fields, I'm using checkbox fields so the user can just "x" the box ]
    <%A5 ?substr(SESSION.MTG1,1,2)+"-"+substr(SESSION.MTG1,4,2) %><br><%A5 ?substr(SESSION.MTG1,7,4)%>

    The session variables were still a struggle; it appears (at least after my umpteen million attempts with different formats)
    that Session.variables can not be assigned as arrays. If anyone knows otherwise, and has demo code to share, great!

    I removed all array references.
    I was then initializing my session.variables in OnGridInitialize. Still, I could not get them to show up in any of my field references (Calc Grid Fields)
    I then moved all the session.variable assignments to OnGridExecute; STILL, no luck (I have used session variables before, and did not have this kind of trouble!)

    FINALLY I resolved my session.variable references with one simple change:

    Instead of assigning them with SESSION.VARNAME='var' as the examples in the event show,
    I used e.rv.session.varname = 'var' and walah !! everything worked perfectly.

  4. #4
    Member cgorman426@gmail.com's Avatar
    Real Name
    Colin Gorman
    Join Date
    Oct 2012
    Location
    Freehold, New Jersey
    Posts
    20

    Default Re: Session Variables as Date values in Array? Access Session Variable from Javascri

    Kim,
    Glad it worked and that's interesting about the e.rv.session.varname, I have never used that.
    Let me know if you need anymore help!!

Similar Threads

  1. Access a session variable in the Javascript Event
    By Jahnel in forum Application Server Version 10 - Web/Browser Applications
    Replies: 13
    Last Post: 09-14-2011, 06:21 AM
  2. how to transfer session.variables between Javascript on HTML-page?
    By René Stout in forum Application Server Version 10 - Web/Browser Applications
    Replies: 5
    Last Post: 05-25-2011, 07:24 AM
  3. Dim array session variables
    By TheMobileGuru in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 12-14-2010, 10:06 AM
  4. JavaScript vs. Session variables
    By Peter.Greulich in forum Archived Wishlist
    Replies: 2
    Last Post: 06-08-2010, 04:27 PM
  5. V10 Can session variables be ref'd in Javascript?
    By ismac in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 08-24-2009, 12:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •