Forum Discussion

JasonJohnson's avatar
JasonJohnson
Qrew Assistant Captain
7 years ago

Is it possible to mark a record (formula checkbox) when it has been 'saved as spreadsheet'?

I have a table that I need to track when records are 'saved as spreadsheet' by end users. This would enable me to create some automation's related to this activity.

3 Replies

  • Rather than allowing users to natively save as a spreadsheet, you can give them an icon/button to download. It would essentially be a url link to a report where the format of the report is set to csv. 

    So prior to directing them to the URL, you can make an api add record call and log that info in a field which puts a timestamp and user info. And you formula checkbox can be driven off that field.
  • This is easy to do with a Service Worker. You can arrange for a Service Worker to detect when a particular pattern of URL is requested and take the appropriate action. In the case of Save as spreadsheet a URL is fetched that has the following query string:

    ?a=q&qid=1&dlta=xs~

    Although a Service Worker has the ability to (1) modify or (2) substitute either the request or response in this case we will do neither and simply make a supplemental call to API_AddRecord recording the dbid and qid to a logging table. It is a ridiculously simple script to do what you ask.

    There seems to be a lot of confusionfear and loathing over the role of using Service Workers with QuickBase. The best minds in the industry have contributed to the development of the Service Workers API and they are safe to use and extremely useful. Developers are simply unaccustomed to using Service Workers as the capability has never existed before so they have no similar experience to draw on.

    All browsers have support for the Service Worker API at this point (Apple is the last holdout but has support in Safari 11.1) and the Service Worker API has been adopted by several cloud service companies as part of their Edge Computing initiatives. This includes Cloudflare where they have adopted the Service Worker API and named it CloudFlare Worker which operate at the edge.

    Cloudflare Workers
    Run code at the edge, deliver powerful web extensibility
    https://www.cloudflare.com/products/cloudflare-workers/
  • Visit this demo page:

    Log Spreadsheet Downloads
    https://haversineconsulting.quickbase.com/db/bnius2h9z

    You now have a Service Worker registered. I authored the page and you have no choice in the matter.  Service Workers are considered to be part of the authored page and they are constructed to perform a helpful task when users interact with my page - namely to log spreadsheet downloads. Unlike for example geo-location - which gives up user information and requires permission to be granted - Service Workers do not require permissions as they don't in themselves deal with user information.

    Now visit any of these reports and proceed to download as a Spreadsheet:

    List All
    https://haversineconsulting.quickbase.com/db/bnius2ia3?a=q&qid=1

    List Changes
    https://haversineconsulting.quickbase.com/db/bnius2ia3?a=q&qid=2

    By Factor
    https://haversineconsulting.quickbase.com/db/bnius2ia3?a=q&qid=5

    By Environment
    https://haversineconsulting.quickbase.com/db/bnius2ia3?a=q&qid=6

    You will get the report downloaded as normal. However, if you visit the Logs table you will now see you have create a log entry reflecting your selected report.

    Pastie Database
    https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=646

    Notes:

    (1) This demo was developed very rapidly while watching the local news. There are some things I would do slightly differently for a production application but at this point it is probably most important to understand what Service Workers can do.  These suckers are extremely powerful and they are rightly called god mode for QuickBase.