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



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

Trouble setting up session variables

  • Filter
  • Time
  • Show
Clear All
new posts

    Trouble setting up session variables


    I am trying to setup an argument to use in a filter condition for a field in a FormView control. I am using a list editor on the field, and trying to populate the edit list with values from a field of another table.

    I have setup an argument called idofsite which I have made equal to the siteid session variable:

    idofsite = :siteid

    I have also setup a client side data cache (which is used in the editor of the formview control) which does a query on the locations table qualified with a filter:

    "WHERE site_id = :siteid.

    :siteid is setup as a session variable which contains the value selected in the site dropdown.

    As per a previous post, I am using a ajax callback and an xbasic function to setup the value in the session variable :

    JS code...

    //Get the value in the site dropdown
    var val = {dialog.object}.getValue('site');

    //Ajax callback

    The xbasic function...

    function setMySessionVariable as c (e as p)

    dim value as c

    value = e.__val

    session.siteid = value

    end function


    I can run the query from the client side data cache SQL genie, and it runs fine by manually entering the siteid value. However, it won't run from code. It always returns the values based on the default siteid value.

    So the ajax callback/xbasic function doesn't appear to be properly setting the value of the session variable (siteid). Help muchly appreciated.


    Re: Trouble setting up session variables

    1. You're using an "Editor-List" as an Editor for a FormView field. You're trying to filter this Editor-List with a session variable based argument

    I have also setup a client side data cache (which is used in the editor of the formview control)
    This part isn't very clear. You have created a client-side data cache. Used where? In the editor for the FormView control? Which editor... the Editor-List?
    How are you using the Data Cache?

    3. You're going about using session vars the long way around. You're trying to filter something client-side... with a value you have client-side. So... you're taking this client-side value and sending it to the server... assigning it to a session var. Then you're trying to use that session var... client-side. I don't think a session var is required here... but let's see.

    If you can explain #2 a bit better... then we can see what's actually required.

    You may be better off defining your Argument as "Set value at Run-time" and pointing to your "Site" field... since you already have that value.


      Re: Trouble setting up session variables

      Hi David,

      Thanks for replying. OK, so session variables are on the server side. This is what I don't want, so no point using a session variable in that case.

      To explain a little more.........I'm using 3 dropdown boxes to select the client, a job from that client and then a site for the selected job. I then display a list control to show the list of assets for the selected client, job and site.

      When I click on one of the assets in the list, I bring up a formview control with the fields being displayed. Some of these fields are edited with an Editor-Text, others with an Editor-List.

      For the Location field, when I click on it, I bring up the list editor. In the formview configuration genie, there are only two choices for the list data source: static or client-side data cache. Static only takes data from a JSON, which is not what need. I need to query the locations table in the db and return a list of locations where the site id is set to that chosen in the site dropdown. ( which should do a query to the locations table, with a WHERE site_id = :idofsite. )

      idofsite is an argument I have defined. I have tried to setup the argument, trying both "get value from variable" and "Set value at runtime". I can't get either option to work. (also, I was thinking in the end that "set value at runtime" required an input from a pop-up dialog box ???)

      I know it is just the argument substitution that's not working, as I can run the query from the SQL genie, manually enter the value of idofsite, and get the correct list of locations back.

      If I set it to "set value at runtime" I can select the value from the site dropdown (which appears in the selection list as {site} which is the name I have used in the setup of the site dropdown box).

      I know it is being set to the correct value, as I have displayed it in an alert message box. But the list of location names returned when I click on the field in the formview is always based on the default value I used in the config.

      Also, I wondering if it is a character vs numeric issue ? I have tried setting the site variable and idofsite argument to both 'c' and 'n' but no difference. (note that the table field I am filtering on: side_id is an INT in the db).

      Thanks again for your help.



        Re: Trouble setting up session variables

        Hi David,

        Thanks for pointing me in the right direction. I've setup the argument to "set value at runtime" which, after a lot of debugging, I have now got working. Apart form some configuration issues, I needed to insert a refreshlistdata operation into the window onshow event to trigger the sql query to refresh the list data.

        Regarding your comment about "Groups", are you referring to security groups or data groups in the formview control ?



          Re: Trouble setting up session variables

          What you want to do is fairly straight forward... although there are a few pieces.

          Your client-side data cache is setup to return data from a table. The data cache setup allows you to create an Argument (a global Argument for the UX) and you're getting the value for this argument from a DropdownBox control on the UX... using the "Set value at runtime" option of the Argument.

          When your DropdownBox value changes, you Refresh the Client-side data cache. There's an Action for working with the Client-side Data Cache and one of the options is to Refresh a data cache item.
          This Refresh action also allows an "onComplete" event... which is where you can use the .refreshListData() method on the Editor-List

          Is this how things are set up?

          I don't think I made a comment about "Groups".


            Re: Trouble setting up session variables

            Yes, agreed. It is fairly straight forward. However, this is my first project on Alpha, so its been a bit of a learning curve for me!

            So, yes this is how I am doing it. Except for the client side data cache action. I just cannot get it to work. Actually when I use it in my dropdown Onchange event, it seems to prevent the refreshdropdownchoices operations from working on my other dropdown boxes. Not sure why this is happening ?

            I have been using the .refreshListData method on its own, and that seems to be working fine. (according to the description, if the list data is based on an sql query, it will initiate the sql query to refresh the data). This is exactly what is happening. I also assume it will refresh the client side data cache at the same time?

            Also, I have my editors in a ContainerWindow so they 'pop-up' when I click on a field in the FormView control. It seems the only place the list refresh works correctly is if I place the refreshlistdata method in the onShow event of the container window.

            (sorry about the comment on "Groups" - it was meant for another thread).



              Re: Trouble setting up session variables

              Understood... I'll always be on that curve.

              I think you're doing things a bit the wrong way around. .refreshListData() will refresh the List... but it will not refresh the data cache.

              Refresh the data cache... and in that Action's onComplete event, run the .refreshListData() method.

              The cascading DropDownBoxes have no effect on anything else... this whole process works. The onChange event of your Site DropDownBox will fire off the data cache refresh... which will, in turn, refresh the List.

              The only other way to get this done is a bit more involved.

              The data cache part is fine, but you can remove this part if you want to. However, doing so involves an Ajax Callback to the server, Xbasic code and Javascript code.

              The DropDownBox onChange event would fire off a Javascript method to make an Ajax Callback. The callback function would query the sql database and return rows. Return Javascript code from the callback would update the Editor-List control with the returned data.

              In essence, you'd be doing the work of the data cache.


                Re: Trouble setting up session variables

                OK, got it sorted now. If I place the refresh client side cache action in the click event of the submit button, it works fine. For some reason, if I put it in the onChange event of the last dropdown box it stuffs up the cascading dropdowns - the selections don't appear in the second dropdown when I make a selection in the first dropdown ???? (I have verified that the select transaction for the second dropdown never gets to the DB when I make a selection in the first dropdown, so seems like alpha is not sending it).

                Next to update the formview control when the list of records in the asset selection list box changes ?? Any ideas here.....when I change the list of records, the last selected record stays in the formview control. I want to update it with the first record in the new list of records.



                  Re: Trouble setting up session variables

                  You may be running into an issue I found while testing your scenario. Does your browser console show an error?

                  Action Javascript (in this case Data Cache Refresh) can be converted to it's Javascript code. Get into the onChange event of your Site DropDownBox control... where you've got your Action Javascript for the Data Cache Refresh defined. Along the top of this dialog is a radio button labelled "Text mode". Select that, you'll get a warning, click Yes. You'll see similar to this...

                  var _refresh = function() {
                  Your data cache item name will be different... as well as your Editor-List listbox name.

                  The issue is with the "_refresh" function. Add a semi-colon to the closing brace... and save it.

                  var _refresh = function() {
                  This is the code generated by Alpha when the UX is rendered. Normally, it's ok... but when used in the onChange event of a DropDownBox control it throws an error without the semi-colon.


                    Re: Trouble setting up session variables

                    Confirming the semi-colon fixed the problem. Thanks again.