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

Publish Session Variable and hide/show buttons

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

    Publish Session Variable and hide/show buttons

    I have been battling this for a couple of days now......I am obviously missing something.....

    I have a grid with two date fields :

    Deadline

    RegOpen

    I am setting a session variable (SESSION.TODAY) to: date()

    Published Session Variable is: SESSION.TODAY

    I want a grid button to show if:

    SESSION.TODAY >= RegOpen AND SESSION.TODAY <= Deadline


    What am I missing? Any help would be greatly appreciated!

    Greg

    #2
    Re: Publish Session Variable and hide/show buttons

    Make sure that the format is the same for all your dates.

    Try formatting the session variable: DTOC(Date())

    Comment


      #3
      Re: Publish Session Variable and hide/show buttons

      Aren't all session variables Character types in V11? Wouldn't you need to convert the session variables from a character to a date type for comparison?
      Alpha Anywhere latest pre-release

      Comment


        #4
        Re: Publish Session Variable and hide/show buttons

        You may have better luck using a javascript function that does the comparison and returns true or false.

        Comment


          #5
          Re: Publish Session Variable and hide/show buttons

          Thanks for the help....I have tried the DTOC and CTOD.....always get a javascript error. Andy, your suggestion sounds promising....I am a newbie at javascript. I have tried a few things downloaded off various sites without much luck. Have even tried the e._state option shown in one of the dialog videos.....still no luck

          Comment


            #6
            Re: Publish Session Variable and hide/show buttons

            Greg, have you considered another option:

            You kan also use an icon in stead of a button. It has the same events as a button. But with an icon you have also access serverside hide/show options.
            Then you can do everyting in Xbasic and don't need a session variable at all.

            On the other hand if you want to use client side events with a button you need to follow Andys suggestion (javascript). I'm sorry that i have also not a ready example for that.
            Ger Kurvers
            Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.1 - 8722-5683(testing)
            Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

            Comment


              #7
              Re: Publish Session Variable and hide/show buttons

              Ger

              That is GREAT suggestion! Let me give it a try and let you know how it goes! Thanks!

              Comment


                #8
                Re: Publish Session Variable and hide/show buttons

                This works for me:
                'OnGridInitialize
                SESSION.TESTDESCRIP2 = DTOC(Date()) ' This loads the value on the Server Side
                'Published session variables
                SESSION.TESTDESCRIP2 ' This loads the value on the Client Side (Make sure on Client Side that it is ALL CAPS)
                'ClientSideProperties/Show/hide expression
                SESSION.TESTDESCRIP2 < DateBeg ' Now that value can be used on the Client Side Properties

                Comment


                  #9
                  Re: Publish Session Variable and hide/show buttons

                  Lee, are you not comparing 2 strings and hoping that, by chance, they compare favorably?

                  Greg, to get you started (totally untested - I am not near a development machine, so this is largely copy and pasted from google):


                  Define this function, and call the function in your button's show/hide clientside test...

                  Code:
                  function isBetweenDates(){
                  
                      //can't remember offhand whether rowNum is passed in automatically......you'll have to check
                      ///EDIT below line ADDED
                      rowNum={Grid.Object}._selectedRow
                  
                      var date1 = {Grid.Object}.getValue('G','MYDATE1', rowNum); //string
                      var date2 = {Grid.Object}.getValue('G','MYDATE2', rowNum);
                  
                      //date1
                      var date1 = date1.split("/"); //now array
                      var year = date1[2]; var month = date1[1]; var day =  date1[0]; 
                      date1=new Date(year, month - 1, day); //now date
                  
                      //date2
                      var date2 = date2.split("/");
                      year = date2[2];  month = date2[1];  day =  date2[0]; 
                      date2=new Date(year, month - 1 , day) //Month is 0-11 in JavaScript
                  
                      //today's date
                      var today = new Date();
                  
                      //now, simply compare the dates as you wish
                      if(today>=date1 && today<date2) {
                        return true;
                      } else {
                        return false;
                      }
                  
                  }
                  Last edited by agillbb; 11-16-2012, 06:51 PM.

                  Comment


                    #10
                    Re: Publish Session Variable and hide/show buttons

                    Thank you Lee and Andy for your efforts. I did try your suggestion Lee and ran into some issues with the accuracy of the string comparisons.....Andy, I will give your solution a try. Being a newbie on JS, I will have to digest things a bit......but I know how important it is for me to understand JS....so it is worth the effort! I will let you know how it goes....thanks again!

                    Comment


                      #11
                      Re: Publish Session Variable and hide/show buttons

                      I know the format of DateBeg and I know the format of TESTDESCRIP2 so therefore I know how to compare. Greg if you look at it this is a format issue.

                      Comment


                        #12
                        Re: Publish Session Variable and hide/show buttons

                        Thanks Lee...I will definitely study it further....I'm sure it was something I was doing wrong. I really appreciate the help.

                        Comment


                          #13
                          Re: Publish Session Variable and hide/show buttons

                          Andy

                          Thank you again for your efforts (and edited code). I have placed this code into the javascript functions for the grid

                          function isBetweenDates(){

                          //can't remember offhand whether rowNum is passed in automatically......you'll have to check
                          ///EDIT below line ADDED
                          rowNum={Grid.Object}._selectedRow

                          var date1 = {Grid.Object}.getValue('G','OPENDATE', rowNum); //string
                          var date2 = {Grid.Object}.getValue('G','DEADLINE', rowNum);

                          //date1
                          var date1 = date1.split("/"); //now array
                          var year = date1[2]; var month = date1[1]; var day = date1[0];
                          date1=new Date(year, month - 1, day); //now date

                          //date2
                          var date2 = date2.split("/");
                          year = date2[2]; month = date2[1]; day = date2[0];
                          date2=new Date(year, month - 1 , day) //Month is 0-11 in JavaScript

                          //today's date
                          var today = new Date();

                          //now, simply compare the dates as you wish
                          if(today>=date1 && today<=date2) {
                          return true;
                          } else {
                          return false;
                          }

                          }
                          And I have placed the following call into the show/hide expression for the button:

                          isBetweenDates()=true

                          But the button does not appear when the true condition should be met. What am I doing wrong? I have spent quite a bit of time with this but seem to be missing a key concept.

                          Thank you again for your efforts.

                          Greg
                          Last edited by gregincolumbus; 11-17-2012, 02:26 PM.

                          Comment


                            #14
                            Re: Publish Session Variable and hide/show buttons

                            Ok...here goes....

                            1) The above code assumed a date format of d/m/yyyy. You need to tweak the code as necessary. e.g. If your dates are m/d/yyyy, then you should be using
                            year = date2[2]; month = date2[0]; day = date2[1];

                            2) Use this clientside show/hide function call instead... isBetweenDates(DateField1, DateField2)
                            Note that there is no need to test whether it is true.

                            3) I have tweaked the code for you assuming you are m/d/yyyy and that you will use the different function call above.

                            Code:
                            function isBetweenDates(date1, date2){
                            
                            	//date1 and date2 come in as strings
                            	//assume date string format is m/d/yyyy - change below definition to suit
                            
                                //date1
                                var date1 = date1.split("/"); //now array
                                var year = date1[2]; var month = date1[0]; var day =  date1[1]; 
                                date1=new Date(year, month - 1, day); //now date
                            
                                //date2
                                var date2 = date2.split("/");
                                year = date2[2];  month = date2[0];  day =  date2[1]; 
                                date2=new Date(year, month - 1 , day) //Month is 0-11 in JavaScript
                            
                                //today's date
                                var today = new Date();
                            
                                //now, simply compare the dates as you wish
                                if(today>=date1 && today<date2) {
                                  return true;
                                } else {
                                  return false;
                                }
                            
                            }

                            Comment


                              #15
                              Re: Publish Session Variable and hide/show buttons

                              Andy,

                              Thank you so much for your assistance on this......the light bulb went off in my head after your last post. It was a date format issue. Once I made the changes, it worked perfectly. I even added some code to return false if date1 was null. This was needed because the deadline date could be null. This resulted in the button appearing, which was not desired. Here is the code I ended up with.

                              function isBetweenDates(date1, date2){

                              rowNum={Grid.Object}._selectedRow
                              var date1 = {Grid.Object}.getValue('G','OpenDate', rowNum); //string
                              var date2 = {Grid.Object}.getValue('G','Deadline', rowNum);

                              if(date1 === undefined)
                              return false;

                              //date1
                              var date1 = date1.split("/"); //now array
                              var year = date1[2]; var month = date1[0]; var day = date1[1];
                              date1=new Date(year, month - 1, day); //now date

                              //date2
                              var date2 = date2.split("/");
                              year = date2[2]; month = date2[0]; day = date2[1];
                              date2=new Date(year, month - 1 , day) //Month is 0-11 in JavaScript

                              //today's date
                              var today = new Date();

                              //now, simply compare the dates as you wish
                              if(today>=date1 && today<=date2) {
                              return true;
                              } else {
                              return false;
                              }

                              }
                              Once again, thanks for all your help. I greatly appreciate it

                              Comment

                              Working...
                              X