1 2 Previous Next 25 Replies Latest reply on Jun 27, 2017 5:56 PM by tinhx7

    Employees Clock In

    tinhx7

      Hi guys,

       

      I created scripts for technicians to clock in and clock out are working fine.

      However, I want to add an option where managers can select several technicians in the check boxes to clock in.

      If the user(s) already clock in (Clock In field isn't empty & Clock Out field is empty), then prompt the manager that user(s) are clocked in, no need to clock in again.

      The check boxes are global field.

       

       

       

      The time sheet is like this:

       

      Date      Technician       Clock In            Clock Out      Total Hour

       

       

      The checkboxes look like this:

       

      Technician A      x

      Technician B   

      Technician C      x

      .....................

       

      I need some suggestion about this script:

       

       

      Enter Find Mode [ ]

      Loop

      Exit Loop If [ Get ( FoundCount ) > ValueCount (  Menu::g_Technician  ) ]

      Set Field [ Time Clock::Technician ; GetValue (  Menu::g_Technician  ; Get ( RecordNumber ) ) ]

      New Record/Request

      End Loop

      Perform Find [ ]

       

       

      Set Error Capture [On]

       

       

      If isEmpty [Time Clock::Clock Out] & not isEmpty [Time Clock::Clock In]

      Show Custom Dialog [ Title: "Alert, This Technician already clocked in."; Default Button: “OK”, Commit: “Yes” ]

      Halt script

      End If

       

       

      Set Field [Time Clock::Technician; Menu::g_Technician ]

      Set Field [Time Clock::Date; Get (Current Date) ]

      Set Field [Time Clock::Clock In; Get (Current Time) ]

       

       

      Exit Script

        • 1. Re: Employees Clock In
          philmodjunk

          Hard to tell exactly how you've set this up, but it looks like your script should

           

          Find for one selected technician for the current date at a time and create a new record if the record is not found.

           

          Set Error Capture [on]

          Loop

             Set Variable [$K ; value: $K + 1 ]
             Exit Loop If [$K > ValueCount ( Menu::g_Technician ) ]

             Enter Find Mode [ ]

             Set Field [ Time Clock::Date ; Get ( CurrentDate ) ]

             Set Field [ Time Clock::Technician ; GetValue ( Menu::g_Technician ) ]

             Perform Find [  ]

             If [ Get ( FoundCount ) = 0 ]

                New Record/Request

                Set Field [Time Clock::Technician; GetValue ( Menu::g_Technician ; $k ) ]

                Set Field [Time Clock::Date; Get (Current Date) ]

                Set Field [Time Clock::Clock In; Get (Current Time) ]

             Else

                 Show Custom dialog [ GetValue ( Menu::g_Technician ; $k ) & " is already clocked in" ]

             End If

          End Loop

          1 of 1 people found this helpful
          • 2. Re: Employees Clock In
            tinhx7

            Thanks for the prompt reply, Phil.

            I don't have the database open right now, but will try it tonight.

             

            Your script looks nice, and clean.

            Question:

            If technician A already clocking in today, and hasn't clock out yet.

            Will the script prevent the manager from clock in the tech again?

            • 3. Re: Employees Clock In
              Oleksiimorgun

              I think you should not be using a global field for a checkbox, as global field shares one value across all records in the table.

              1.JPG

               

              As an option, use a text field (not global), it should belong to TimeClock table. In your script, perform find on not empty values, then loop through each record, set your clock in/out time. If the "Set Field" returns no errors, set checkbox value to NULL

              • 4. Re: Employees Clock In
                philmodjunk

                The script assumes that if a record for a given technician has today's date, they are already clocked in and it shows a custom dialog and does nothing else but advance to the next technician. If technicians clock in and out multiple times in the same day, this script will need modification to find only for records with today's date and an empty "clock out" field.

                • 5. Re: Employees Clock In
                  tinhx7

                  Understood.

                  Thanks Phil.

                   

                  @Oleksiimorgun ,

                   

                  Not sure if we're on the same page, but the actual technicians table is a text field.

                  But in the Time Clock, I create & set the technician field as global.

                  It's working fine for me.

                  • 6. Re: Employees Clock In
                    sai

                    I don't know if you have shifts, but keep in mind if you do that someone could clock in yesterday and out today.

                    • 7. Re: Employees Clock In
                      philmodjunk

                      To handle the situation where a shift might start before midnight and end after, you can use timestamp fields instead of time fields.

                      • 8. Re: Employees Clock In
                        tinhx7

                        I'm thinking replace the date field with these.

                        So it doesn't matter what date they forgot to clock out, managers will not able to clock in them , but fix their hours first.

                         

                        Set Error Capture [on]

                        Loop

                           Set Variable [$K ; value: $K + 1 ]
                           Exit Loop If [$K > ValueCount ( Menu::g_Technician ) ]

                         

                           Enter Find Mode [ ]

                         

                          Set Field [ Time Clock::Clock In ; "*" ]

                          Set Field [ Time Clock::Clock Out ; "=" ]

                          Set Field [ Time Clock::Technician ; GetValue ( Menu::g_Technician ) ]

                         

                           Perform Find [  ]

                        ....................

                        • 9. Re: Employees Clock In
                          philmodjunk

                          That can be made to work, but I wonder if other approaches might be better--such as having the manager pull up a list of all active employees that should be working today with a field or indicator showing who are clocked in, who are not and who failed to clock out from their previous shift. Instead of clicking check boxes to create a list of technicians to clock in, you simply click buttons in this list to fix the issues shown in this list view of your employees.

                          • 10. Re: Employees Clock In
                            tinhx7

                            philmodjunk

                             

                            Your solution works for me.

                            However, it didn't clock in the other technicians if one of the tech already clocked in.

                            • 11. Re: Employees Clock In
                              philmodjunk

                              That shouldn't happen. Your original script had a halt script where it shouldn't be. Did you perhaps add a Halt script step after the custom dialog? My suggested script does not do that.

                              • 12. Re: Employees Clock In
                                tinhx7

                                My bad, you're correct, sir.

                                 

                                Thanks again.

                                • 13. Re: Employees Clock In
                                  tinhx7

                                  .

                                   

                                   

                                   

                                  • 14. Re: Employees Clock In
                                    philmodjunk

                                    That looks like a script that could be simplified quite a bit, but the immediate problem appears to be a missing Enter Find Mode step.

                                    1 2 Previous Next