Forum Discussion

GeromeRich's avatar
GeromeRich
Qrew Trainee
4 years ago

Record who presses a URL Button

Hi,

We are using QB as a Knowledge Hub, uploading documents from our various projects and programmes.  The documents are our companies IP.

Accordingly we want to be able to track who is downloading the documents as we do occassionally give access to contractors.

To cover off on access restrictions we don't display the file attachment in records or reports for general users.  I have a URL Button that tests that a <Restricted Access> checkbox is not ticked, and that a document actually exists.  If these two criteria are met, the button appears and is able to be pressed which downloads the document.

Code for the button is here:

If([Restricted Access]=false,If(ToText([Attachment])<>"",
URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0"))

What I would like to be able to do is each time the button is pressed, record the user pressing the button in a log field.  Date and time would be a bonus, but could live with just user name.   
Basically just need to copy Current User and potentially date to a text field, that has the <log> button ticked!

Any help greatly appreciated in how we add this to the URL if it is even possible at all.

Cheers


 




------------------------------
Gerome
------------------------------

4 Replies

  • It would be better to have a child table to log who viewed the file as the logged field could get to be very long, but try this.  I am using formula variables to break up the formula into smaller pieces.


    var text Log = URLRoot() & "db/" & Dbid() &  "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_99=Viewed"; // replace 99 with the logged field with logging the time enabled..

    var text ViewFile = URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0";

    var text LogAndView =
    $Log
    & "&rdr=" & URLEncode($ViewFile);


    If([Restricted Access]=false and ToText([Attachment])<>"",
    $LogAndView)

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • GeromeRich's avatar
      GeromeRich
      Qrew Trainee
      Awesome!

      Thank you very much Mark!

      For those playing at home, you can't use Log as a variable, so just changed to Loog and it worked perfectly.  (I didn't know that, QB told me.)

      I just need to insert the app token into the formula and we are all good, turn app tokens back on and we are all good!

      The child record approach might be much better, as then we could quite easily search and aggregate data on who is downloaded what, and how much.  Pointers for this appreciated.  (If complicated or stretching the friendship i can live with this solution for now!)

      Thanks again.

      Gerome


      ------------------------------
      Gerome Rich
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        This is the line which edits the record to update that log field.

        var text Log = URLRoot() & "db/" & Dbid() &  "?act=API_EditRecord&rid=" & [Record ID#]
        & "&_fid_99=Viewed"; // replace 99 with the logged field with logging the time enabled..

        If you make a child table to the main table with the file on it, you can populate the field for Related Knowledge Hub record.

        so you can change that line to just this.
        var text Log = URLRoot() & "db/" & Dbid() &  "?act=API_AddRecord"
        & "&_fid_10=" & [Record ID#]
        & "&apptoken=xxxxxxxxxxxxx";

        Normally when adding a child record you would also populate specific fields. But in this case the record owner will be the person who pushed the button and of course the date created will be the date and time that the record was created.  So the only field that we need to update is the field for related Knowledge hub record.  so you would replace the 10 with the field ID for that field.  Since the value we want to populate into that field for Related Parent is of course the Record ID of the Parent then we just put the Record ID into that field because we are in fact launching the button off the parent record. 

        And yes you are correct that I neglected to mention that if you have left the need for application tokens enabled then you do need to provide the application token when you are adding or editing records. 


        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------