Is there a way to get the last login date for a user only using the Quickbase API?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

I have an external program that needs that information. Any way to do this indirectly is appreciated.

Photo of Afton

Afton

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Jesus

Jesus

  • 0 Points
Under any app, click on the USERS tab (you need to be an admin or have permission to view it) and it will display a list of all the users, their roles, as well as the last date they were logged in.

Hope it helps.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
There is no API for this particular set of information but you can create your own API and snag any information availaile in any QuickBase page. This is called the "Be The API Technique" and I have started to write a book on the topic. So far all I got is the cover designed but I am making great progress:

http://i.imgur.com/QfDutxu.jpg

The code in the attached pastie record does exactly this and returns through a promise an array of user names and their corresponding lastVisit times (as a string). I am short time as I have to travel in a few minutes but if you have questions feel free to ask.

[
 {
    "name": "Dan Diebolt",
    "lastVisit": "July 27, 2015 9:01 AM (CST)"
  },
  {
    "name": "Jane Doe",
    "lastVisit": "July 26, 2015 8:32 PM (CST)"
  }
]

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


Notes

(1) The code in the pastie loads a hidden <iframe> into the present QuickBase page and proceeds to extract the required information from the rendered table. The selectors are fragile but it works.

(2) There is a JavaScript object named userData in the ?a=manageusers page which contains required informaiton. However since the variables is in a closure there is no way to access through an <iframe>. However, you could just do an AJAX call for the same page and extract the text out of the page and parse the result with JSON.parse(). This result contains more data than you need and has this format:

http://pastie.org/10314731
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
I meant to post this earlier so I hope it is still useful. In note (2) above I indicated you could do an AJAX call and parse out the userData structure using JSON.parse(). This is true but unfortunately the userData structure is technically not in JSON format in QuickBase's page. So you can still do it but you have to convert it to JSON by double quoting the property names and perhaps perform some other minor fixes. There is an easier alternative:

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


Here is the information contained in userData which you can see contains the last login time and a whole lot more information:

http://pastie.org/10322420


This code uses a regular expression to parse out the userData assignment as an string and then eval()'s it thus yielding a variables that contains all the last login times and a whole lot more. Now most developers would say NEVER use eval(). I disagree in this instance. There is no foul in using eval() in this fashion if it is the administrator who simply needs to gather the last login information for legitimate administration purposes. It would be another matter altogether if you were using eval() on a page where a general user could supply random input to the eval().

If you want more information on this consult these resources:

Angus Croll: Break All The Rules
https://www.youtube.com/watch?t=10&v=MFtijdklZDo

eval() Considered Useful
http://blog.berniesumption.com/software/eval-considered-useful/