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

Current Date / Time in a Grid Component?

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

    Current Date / Time in a Grid Component?

    Hi, I am trying to display the current date and time in my grid component (In the Detail View) and can't seem to get anything except the default time to show up. The "Initial Value" property for my Time and Date fields explains that I can use either =date() or =now() etc - but they do nothing. (Have got this to work perfectly in Dialog2's before.) Ideally I want the fields to update with the current date and time every time a certain field is changed (onChange event).

    Is there any way of doing this? Any help much appreciated - Thanks,

    Leon.

    #2
    Re: Current Date / Time in a Grid Component?

    Hi Leon

    If I understand you correctly, you want to capture the current date and time when a certain field is updated. I'm not sure about an individual field, but in most of my grids I capture the current date, time & User Name upon the initial creation of the record, and in a separate set of fields, I capture the date/time/User Name each time the record is updated.

    Then I display that information on the grid.

    Would that suffice, or do you have to specifically have to focus on that one field?
    Attached Files
    Sergeant Richard Hartnett
    Hyattsville City Police Department
    Maryland

    Comment


      #3
      Re: Current Date / Time in a Grid Component?

      Hi Rich, yes that's correct - with an onChange event. Capturing the date and time when the record is updated would be sufficient, as I can make the record save on that same onChange event to give me the same result. How did you go about doing this?

      Thanks,
      Leon.
      Last edited by Leonw43; 07-17-2013, 07:20 AM.

      Comment


        #4
        Re: Current Date / Time in a Grid Component?

        Well Leon I do it a bit differently than what you are looking for, but the end result may be the same so here's how I do it:

        In all my tables where I want to capture the date/time/User that first creates the record, and the date/time/user that last makes any changes to it, I start by creating 6 fields in the actual table, and those fields must appear in your grid as "updateable" fields, although you can set them to "hidden" so they do not appear to the end user.

        They are:

        DateEntered (date field)
        TimeEntered (character field, 9 spaces)
        EnteredUser (character field, long enough to capture the user's unique ID Number)

        DateUpdated (date field)
        TimeUpdated (character field, 9 spaces)
        UpdatedUser (character field, long enough to capture the user's unique ID Number)

        Now in the actual grid, I go to two sections in the server-side events:

        In the "BeforeValidateNewRecords," I replace the default code with;
        (Which captures the data/time/Ulink (which is my UserID) on the initial entry of the record.)
        ---------------------------------------------------------------------------------------------
        function BeforeValidateNewRecords as v (DataSubmitted as P, Args as p, PageVariables as p)
        with PageVariables
        DataSubmitted.Dateentered=date()
        DataSubmitted.Timeentered=time()
        DataSubmitted.EnteredUser=session.__protected__ulink
        end with
        end function
        --------------------------------------------------------------------------------------------
        Then in the "CanUpdateRecord" section I replace the default code with;

        function BeforeValidateNewRecords as v (DataSubmitted as P, Args as p, PageVariables as p)
        with PageVariables
        DataSubmitted.Dateupdated=date()
        DataSubmitted.Timeupdated=time()
        DataSubmitted.UpdatedUser=session.__protected__ulink
        end with
        end function
        --------------------------------------------------------------------------------------------

        * This captures the date/time/User of anyone making changes to the record, and updates each time a change is made, so it always shows the last person that performed any action on it. (But doesn't tell you which field was actually changed.)

        Incidentally, sometimes I substitue the "session.__protected__ulink" with "session.__protected__Lastname" in situations where I want an actual name recorded instead of just the UlinkID, and still in others I record both.

        Hopefully this will help you.
        Attached Files
        Last edited by Rich Hartnett; 07-17-2013, 10:59 AM.
        Sergeant Richard Hartnett
        Hyattsville City Police Department
        Maryland

        Comment


          #5
          Re: Current Date / Time in a Grid Component?

          Thanks, this helps a lot as I will need to store the log data to my database in a similar way in the future - although for this instance, I need to display the current time and date in the fields of the detail view, triggered by a javascript event. Saving the current time and date into the table isn't enough for what I'm currently doing, as the data also being used from the detail view to send out an email containing the data before it's saved.

          Basically I need the current time / date displayed on the detail view before saving - I mistakenly thought that I didn't need to do this before saving but as it turns out, the email send event is looking at current data on the detail view.

          I have been trying to get the onClick event on a test button to set the value of my time field to the current time, but to no avail.
          I've tried:
          {grid.object}.setValue('D','LOG_TIME',time());
          {grid.object}.setValue('D','LOG_TIME',Date.getTime());
          etc.

          But nothing has worked - am I using incorrect syntax or something here?
          Thanks in advance,

          Leon.

          EDIT: Have found the solution after having another look on the forum:
          http://msgboard.alphasoftware.com/al...e-current-date

          Here is the code I ended up using:
          var d = new Date();
          var day = d.getDay();
          var month = d.getMonth();
          var year = d.getFullYear();
          var hour = d.getHours();
          var min = d.getMinutes();
          var sec = d.getSeconds();
          var full = day+"/"+month+"/"+year;
          var time = hour+":"+min+":"+sec;

          {grid.object}.setValue('D','LOG_DATE',full);
          {grid.object}.setValue('D','LOG_TIME',time);
          Last edited by Leonw43; 07-19-2013, 06:54 AM.

          Comment


            #6
            Re: Current Date / Time in a Grid Component?

            I was searching for a way to have a field updated on record modification too. I have a MySQL backend and use Navicat for working with MySQL tables. Inside Navicat I noticed the "On Update Current_Timestamp" checkbox. This appears when you have your field type set to timestamp in Navicat. Very simple way to accomplish my needs. I am sure this feature would be available in MyPHPAdmin for MySQL db too, Navicat is just a great tool to use.

            2013-11-07_104716.png

            Comment


              #7
              Re: Current Date / Time in a Grid Component?

              correct me if I am wrong but I thought all session variables are protected now so there is no need for the session.__protected__ulink anymore.
              fieldname =session.ulink is secure now as I understand it...
              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


                #8
                Re: Current Date / Time in a Grid Component?

                Originally posted by George Corder View Post
                I was searching for a way to have a field updated on record modification too. I have a MySQL backend and use Navicat for working with MySQL tables. Inside Navicat I noticed the "On Update Current_Timestamp" checkbox. This appears when you have your field type set to timestamp in Navicat. Very simple way to accomplish my needs. I am sure this feature would be available in MyPHPAdmin for MySQL db too, Navicat is just a great tool to use.

                [ATTACH=CONFIG]37105[/ATTACH]
                For those who don't use Navicat -

                If you have a TIMESTAMP field, you can use CURRENT_TIMESTAMP to set a field's value on create or update. It's insanely handy. And I was just too excited when I learned about it a few months ago.
                Code:
                CREATE TABLE foo (
                  ID INT(11) NOT NULL AUTO_INCREMENT,
                  BAR VARCHAR(255) NOT NULL,
                  CREATED TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
                  UPDATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                  PRIMARY KEY (ID)
                )
                More information here: http://dev.mysql.com/doc/refman/5.1/...alization.html
                Alpha Anywhere latest pre-release

                Comment

                Working...
                X