1 Reply Latest reply on Sep 27, 2011 10:09 AM by philmodjunk

    Lock Time Field using button



      Lock Time Field using button


       Good Morning,

      I've created a Time Card layout that has for everyday six fields that would get the current time for timein/timeout for the AM/PM and Overtime. (Employees have to clock out for lunch).   I'd like to create a button script that Gets (CurrentTime) for that particular field and then locks it so no more modifications can be made.

      Because all seven days  have 6 different fields I've tried to use a script using Get (ScriptParameter), but it's not working.

      If [IsEmpty Get (ScriptParameter))] //this would be the AM/PM or overtime fields for each day

        SetField [Get (ScriptParameter);Get (CurrentDate)] //this brings up a box asking for an operator)

      End if

      Can you tell me what I am doing wrong, or point me in a better direction.

      Thank you,

        • 1. Re: Lock Time Field using button

          I think you need to provide a bit more detail. How do you specify your script parameters? Do you have 6 buttons, each with a different parameter? Do they pass a field name to the script?

          If so, this script should work:

          Set variable [$FieldName ; value: Get ( Scriptparameter ) ]
          If [IsEmpty ( getField ( $fieldName ) ) ]
             Set Field By name [ $Fieldname ; Get ( Currentdate ) ]
          End If

          Note 1: GetFieldName ( Table::field ) is a good option for passing a field name as a script parameter. With this expression, you can rename your field in Manage | database | fields and the script will still work.

          Note 2: You may want to use get ( CurrentTimestamp ) instead of separate uses of Get ( CurrentDate ) and Get ( currentTime ). This makes it possible to subtract time in from time out to comptue elapsed time and not have to worry about cases where time in was before midnight and time out was after.