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
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