Forum Discussion

WilliamHunter2's avatar
WilliamHunter2
Qrew Member
12 months ago

Button State

Okay so this one is a big problem for me. I have created an app for the electrical side our company and during beta runs today I have found a very big problem. The code below is for a clock in button that I created that through other mechanisms can tell if the user is late, clocked in on another job, early, or on time/within a 10 minute window. Long story short one if a user hits the button 5 times quickly it will clock the user in 5 times. Is there some way to find the previous state of the button or see if the button was clicked so I can allow them to only clock in one time? I need some way to remove this error if anyone can think of something here. 

//This code takes the job and user record number and places them in the related fields to associate them together. Also, if the user is already clocked in and attempts to clock in again this will show a prompt letting them know they are already clocked in. 

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Clock In URL
var text urlone=
URLRoot() & "db/" & [_DBID_TIME_ENTRIES] & "?a=API_AddRecord&apptoken=c2x3rt7dkx56hnh9ckac49b2tz&_fid_13=" & URLEncode ([Record ID#]) & "&_fid_18="
& URLEncode ([User's Name]) & "&_fid_25=Work" & "&_fid_104=" & URLEncode ([Supervisor])& "&_fid_105=" & URLEncode ([Foreman]) & "&_fid_106=" & URLEncode ([Job Start Time]) & "&_fid_125=true"

//& URLEncode ([Current Users Record - Maximum Record ID# User]) This line of code was dropped from the other code. It passed an alternative field.  

& "&_fid_16=In" & "&_fid_7=" & URLEncode ([dt start]) & "&rdr=" & URLEncode("https://lmisystemsinc-6511.quickbase.com/db/btadwesdf");

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Multiple Job Clock In Warning Code Page
var text urltwo = 
URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=3&copyText=" & URLEncode() & // code page
"&rdrurl=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]);//passed for final redirect


//If([Maximum Record ID# In Current User]<>0,$urltwo,$urlone) //Might re-engage, not sure. This shows a warning when the user is already clocked in.
//Instead of re-engaging the above line this one will be used where the "" will cause the button to become hidden.

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Late Clock In URL
var text urlthree=
URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=10&record=" & URLEncode([Record ID#]) & "&name=" & URLEncode([User's Name]) & "&supervisor=" & URLEncode([Supervisor]) & "&foreman=" & URLEncode([Foreman]) & "&start=" & URLEncode([Job Start Time]) & "&now=" & URLEncode([Now]);


//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//You are early
var text urlfour=
URLRoot() & "db/" & [_DBID_TIME_ENTRIES] & "?a=API_AddRecord&apptoken=c2x3rt7dkx56hnh9ckac49b2tz&_fid_13=" & URLEncode ([Record ID#]) & "&_fid_18="
& URLEncode ([User's Name]) & "&_fid_25=Work" & "&_fid_104=" & URLEncode ([Supervisor])& "&_fid_105=" & URLEncode ([Foreman]) & "&_fid_106=" & URLEncode ([Job Start Time]) & "&_fid_125=true"

//& URLEncode ([Current Users Record - Maximum Record ID# User]) This line of code was dropped from the other code. It passed an alternative field.  

& "&_fid_16=In" & "&_fid_7=" & Now() & "&rdr=" & URLEncode("https://lmisystemsinc-6511.quickbase.com/db/btadwesdf");


//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
If(
    [Maximum Record ID# In Current User]<>0, "",
    [# of Jobs Clocked In On - Total Clocked In - Across All Jobs] > 0, $urltwo,
    [Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) < [Job Start Time]), $urlone,
    [Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) > ([Job Start Time] + Minutes(10))) and [# of Jobs Clocked In On - Maximum Minimum Record ID# - User] = 0, $urlthree,
    [Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) > ([Job Start Time] + Minutes(10))) and [# of Jobs Clocked In On - Maximum Minimum Record ID# - User] > 0, $urlfour,
    [Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) >= [Job Start Time]) and (ToTimeOfDay(Now()) <= ([Job Start Time] + Minutes(9))), $urlfour
    //[Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) < ([Job Start Time] + Minutes(11))) and (ToTimeOfDay(Now()) > [Job Start Time]), $urlone,
    //[Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) > ([Job Start Time] + Minutes(11))) and [# of Jobs Clocked In On - Maximum Minimum Record ID# - User] = 0, $urlthree,
    //[Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) > ([Job Start Time] + Minutes(11))) and [# of Jobs Clocked In On - Maximum Minimum Record ID# - User] > 0, $urlone,
    //[Maximum Record ID# In Current User]=0 and (ToTimeOfDay(Now()) < ([Job Start Time] + Minutes(11))) and (ToTimeOfDay(Now()) > [Job Start Time]), $urlfour
    )



------------------------------
William Hunter
------------------------------

2 Replies

  • After they clock in have the button change so they can't click it again for a few minutes:

    Depending on your setup,  you can use the last modified time on the Time Entry so that the button is hidden or greyed out until 5 mins pass.   Something like this:

    If( ToMinutes(Now() - [Last Modified Time]) >= 5, show button, hide button  )

    If I was doing this,  I would have the button change to a grey button that they can't click that just says 'Please Wait' or something similar and change back to the normal state once the 5 mins has passed.

    I think you could alternately use this as a custom data rule for that table.

    ------------------------------
    Jeff Peterson
    ------------------------------

    • WilliamHunter2's avatar
      WilliamHunter2
      Qrew Member

      Understood. I will see if this works. It looks like the problem is because if you hit the button multiple times then it sends multiple API calls. So, if that doesnt work I will try to pass it off to a "loading" code page. 



      ------------------------------
      William Hunter
      ------------------------------