Announcement

Collapse
No announcement yet.

Current Time

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

  • Current Time

    How can I prime the field on the form with current time ?

    -----------------------------------------
    Arthur Klisiewicz
    dATA POINT SOFTWARE
    www.datapointsoftware.com

  • #2
    wow, nobody ? there should be the way ?
    I'm surprised SC does provide this functionality for the DATE but not for the TIME
    -----------------------------------------
    Arthur Klisiewicz
    dATA POINT SOFTWARE
    www.datapointsoftware.com

    Comment


    • #3
      I think you can do it in onload event, use function php for asign the time to your field. and use macro for verify if is a new record.
      if (sc_btn_new)
      {
      asign the time to your field;...
      }

      Comment


      • #4
        thanks but I still do not know how to do it. I can handle SC macros, but I'm not a PHP programmer
        -----------------------------------------
        Arthur Klisiewicz
        dATA POINT SOFTWARE
        www.datapointsoftware.com

        Comment


        • #5
          ONLOAD RECORD
          if (sc_btn_new)
          {
          {Mytime} = date("h:i:s");
          }

          Comment


          • #6
            thanks - alvagar

            I use another software (for desktop dev) where there are 4 modes for the form. Based on those modes developer can take different actions. This works lika a charm as you can always test what mode is active. For example 1=Inseret 2=Eidt 3=Delete 4=Select
            I wish it would work the same in SC as it makes very easy to perform actions based on the state 1-4


            Ok, so can I do this conditionally ?
            If user adds New Record I want to populate field with current time, but when the user Edits a record I want the data from the database to show up ?
            Another words is there any indicator if the form is opened in INSERT or EDIT mode ?




            -----------------------------------------
            Arthur Klisiewicz
            dATA POINT SOFTWARE
            www.datapointsoftware.com

            Comment


            • #7
              A new ID is not assigned until the new data is inserted, so you can do:

              Code:
              if ( {ID} < 1 ) {
                  {Mytime} = date("h:i:s");
              }
              You can also check for a value in the time field, but that would populate on Edit. If the time is a required field, then it has to be present to insert. If that is the case, you can just check to see if there is a value, then add one if not.

              Code:
              if ( !{Mytime} ) {
                  {Mytime} = date("h:i:s");
              }
              [edit] Forgot about the Button macros. You can tell the state by what button was clicked to get to your form. Check out Scriptcase Macros -> Buttons.
              Last edited by Travelr; 11-04-2015, 03:00 PM.

              Comment


              • #8
                Yes I understand your example, thanks.
                My additional question is how to figure out if the form is open for Inserting or for Editing ?
                -----------------------------------------
                Arthur Klisiewicz
                dATA POINT SOFTWARE
                www.datapointsoftware.com

                Comment


                • #9
                  As travlr posted, by scriptcase macro's Look at the docs at:
                  sc_btn_insert
                  Available when the "Add" button is clicked. Can be tested and used inside the ScriptCase events, allowing especific programmation in run time.

                  Ex. 1:
                  if (sc_btn_insert)
                  {
                  sc_message("Record inserted successfully");
                  }
                  Macro Scope
                  Form application
                  onValidate
                  onValidateFailure
                  onValidateSuccess
                  Below the docs you will find sample for the other states.
                  Albert Drent
                  aducom software netherlands
                  scriptcase partner, reseller, support and (turn-key) development
                  www.scriptcase.eu / www.scriptcase.nl

                  Comment


                  • #10
                    yes, I understand the part about assigning the time.
                    Albert - I'm not getting your suggestions, but perhaps because I'm coming from the desktop programing, where certain things are a bit different.
                    When user clicks NEW (with the intention of adding a New Record) then the grid App (linked to the form) and opens a blank form causing adding a new record - RIGHT ?
                    When user clicks PENCIL icon then the same form opens but instead the form reads the record into the form FIRST - RIGHT ?

                    so what/how it is determined to load existing data into the form OR open empty form ?
                    there must be some variable that allows to make that decission

                    ARTHUR
                    -----------------------------------------
                    Arthur Klisiewicz
                    dATA POINT SOFTWARE
                    www.datapointsoftware.com

                    Comment


                    • #11
                      The form opens normally in insert mode if there are no records in the grid. The form opens in read/edit mode when there are records in the grid. Then you see the new button as Albert said..
                      But I havent tested this in detail, Albert's way is the easy solution.

                      Comment

                      Working...
                      X