Forum Discussion

EdwardHefter's avatar
EdwardHefter
Qrew Cadet
3 years ago

Using printed QR codes to Clock In or Clock Out of a Task

I am setting up a timekeeping system and want to use printed QR codes to clock in and out of specific tasks (the codes would be on the bin of material being worked on).

I have a URL for clocking in and one for clocking out that works, and on the form I have the QR code that has the URL hide or show based on whether the current user is currently clocked in or out. I am trying to have a QR code that will determine which user is logged into the phone that is scanning the QR code, figure out if she is currently clocked in, and then use the appropriate URL.

Any suggestions?

Here is the URL to Clock in (using the "now" rather than "now()" in the URL is nice because I can print it on paper and it is always gives the current time): 
var text redirect = "&apptoken=XXXXXXX&rdr="&URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl());

URLRoot() & "db/br4vigw5t/(_DBID_TIMECARDS)?a=API_AddRecord&_fid_6=" & [Record ID#]&"&_fid_8=Now&_fid_7="&URLEncode(User())&$redirect

Here is the URL to Clock out (this one is convoluted because it has to find the task that the current user is clocked in to and while structurally, they can be in multiple tasks, based on other constraints they are only able to be in one task, which is why using the SumValues function works in this case):
var text redirect = "&apptoken=XXXXXXX&rdr="&URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl());

var text TimecardQuery = "{6.EX."&[Record ID#]&"}AND{7.TV.'_curuser_'}AND{15.EX.0}";

var number CurrentUserTimecardID = Nz(SumValues(GetRecords($TimeCardQuery,[_DBID_TIMECARDS]),29),9999);

URLRoot() & "db/br4vigw5t/(_DBID_TIMECARDS)?a=API_EditRecord&rid="&$CurrentUserTimecardID&"&_fid_9=Now"&$redirect

------------------------------
Edward Hefter
www.Sutubra.com
------------------------------

4 Replies

  • If you're looking for the syntax to generate a QR code, try this as a Rich Text Formula field.  Can you post back to confirm that it works. It's an interesting approach you are using to query for the current user.  


     "<img src=h
    ttp://chart.googleapis.com/chart?cht=qr&chs=240x240&chl=" 
    & URLEncode($URL)& "'>"



    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------
    • EdwardHefter's avatar
      EdwardHefter
      Qrew Cadet
      I already have the QR codes. I am using a different source for them than Google, but I didn't see how to set colors in the Google one, and the colors help people figure out which one to scan.

      Logging in - "<img src=\"http://api.qrserver.com/v1/create-qr-code/?color=00FF00&amp;bgcolor=FFFFFF&amp;data="&URLEncode([Clock In from Task])&"&amp;qzone=1&amp;margin=0&amp;size=250x250&amp;ecc=L\" alt=\"Scan this to log in\" />"

      Logging out - "<img src=\"http://api.qrserver.com/v1/create-qr-code/?color=FF0000&amp;bgcolor=FFFFFF&amp;data="&URLEncode([Clock Out from Task])&"&amp;qzone=1&amp;margin=0&amp;size=250x250&amp;ecc=L\" alt=\"Scan this to Clock Out\" />"

      I am hoping to find a way to have just one QR code that can figure out if the user is already clocked in or out (depending on the user name they are logged in under on their phone) and then do the appropriate Add or Edit action.

      Figuring out if the current user is the one in the field tracking whose time card it is (FID 7) is something I found in the online help, as was using "&_fid_8=now&" rather than "&_fid_8=now()&". Using the formula now() would work find for clicking something online, but not for a printed QR code that isn't dynamic.

      ------------------------------
      Edward Hefter
      www.Sutubra.com
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        I appreciate that lead on alternative methods to generate a free QR code.
        https://goqr.me/api/doc/create-qr-code/

        I can't see how a static QR code could make a decision.  It seems to me that you need to add records to come kind of child table and have logic with Pipelines to decide what to do with that record.  If you set the User field to default to the current user, then you can probably get the ADDRecord API to default that current user into that field.

        ------------------------------
        Mark Shnier (YQC)
        mark.shnier@gmail.com
        ------------------------------