2 Replies Latest reply on Aug 14, 2014 12:11 PM by simmka

    Employee Time Clock Script Not Functioning Correctly

    simmka

      Title

      Employee Time Clock Script Not Functioning Correctly

      Post

           I've tried many variations on this script. This is the furthest I've gotten with it so far that it's been able to pull the data that I need. What I need it to do is:

           When an employee is wanting to clock in or out for the day, they will click a button on the home page layout that will run the below script and take them to a seperate layout (Called "Shift Time") where their day's shift record is either created or edited, depending on if the script finds a record with the employee's account name and the current date (if it finds a record already for that employee on that date it should go to the record and allow editing, if not it should create a new record for that employee on that date).

           The problem I am running into with the below script is that while it does find the correct date information, it's not finding the correct employee information, it's pulling ALL employees for that date. I need it to only pull the employee record that is logged in for the current date.

           Here is the script I'm using:

           Set Error Capture [On]

           New Window [Name: "Shift Time Log"; Style: Dialog]

           Go to Layout ["Shift Time"]
           Perform Find [Restore]
           (the find here is Day Time::Employee Clocked [get(accountname)] AND Day Time::Shift Date [//])
           If [Get ( FoundCount )   >   0]
           Go to Record/Request/Page [First]
           Exit Script []
           Else If [Get ( FoundCount )  = 0]
           Enter Browse Mode []
           New Record/Request
           Set Field [Day Time::Shift Date[]; Get (CurrentDate)]
           Set Field [Day Time::Employee Clocked[]; Get(AccountName)]
           End If
            
           Thanks!

        • 1. Re: Employee Time Clock Script Not Functioning Correctly
          philmodjunk

               You cannot evaluate functions inside stored find criteria in your perform find script step.

               Use this method instead:

               Enter Find mode [] --> clear the pause check box
               Set Field [Day Time::Employee Clocked ; Get ( AccountName ) ]
               Set Field [Day Time::Shift Date ; Get ( currentDate ) ]
               Set Error capture [on]
               Perform Find []

               When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

               To see more examples of scripted finds, see: Scripted Find Examples

          • 2. Re: Employee Time Clock Script Not Functioning Correctly
            simmka

                 Took out the perform find step and implemented your suggestion in its place. It works flawlessly! I tested it using 2 different account names and I tested the date by switching my computer's internal date clock to tomorrow's date...worked every time!

                  

                 Thank you for the fast response!