Discussions

Expand all | Collapse all

Track Changes to a User Field - Even through Grid Edit

  • 1.  Track Changes to a User Field - Even through Grid Edit

    Posted 10-03-2016 16:30

    I'm working on a Project Management app, and we've added a feature to assign a task to a specific user.  I want to log the changes to the Assigned User field in a separate text field, marked "User History".

    Currently I have a system that uses a Formula-Text field to pull the current user's name, and then a form rule that writes that to the User History field on save whenever the assigned user is updated.  The User History field logs changes with timestamps so it's perfect except for one thing... Grid Edit.  

    We often receive hundreds of new jobs at a time, and it's not unusual for them to be assigned en masse.  Grid Edit makes selecting a user quick and easy.  However, since there are no form rules for grid edits, the User History field never gets updated with the new data and the changes are not logged.

    Is there any way to track changes on a User field or Formula-Text field directly?  Neither one seems to give me the option.  That would allow me to keep track of the data without having to resort to the clunky form rule writing it across whenever it changes.



  • 2.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 10-03-2016 17:49
    You could use a Webhook.  But the issue there will be that they gate Webhooks to a maximum of 10 per second.  So I think that if you have a large Grid edit more than 10 changes, it would miss some.  But it would still be better than what it is now with grid edit which is logging nothing form Grid edit.


  • 3.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 06-01-2017 20:12
    This isn't true; a webhook will only be triggered once if multiple records are changed at once with grid edit (or through importing). I have a webhook that does this exact thing and it works perfectly.


  • 4.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 06-01-2017 20:46
    Correct, if you use the import form CSV, that only counts as one import and one webhook.


  • 5.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 10-03-2016 20:12
    Yes it is possible using the IOL technique in grid edit mode. You have to monkey patch the function GeditSubmit(). The jax.params will contain a string of XML in this format which represents the changes made:

    <qdbapi>
        <geRidListStr2000>1~~!~^3~~!~^4~~!~^5~~!~^6~~!~^2~~!~^-10~~!~^-11~~!~^-12~~!~^-13</geRidListStr2000>
        <geDFID2000>0</geDFID2000>
        <geDBID2000>bk8f9xcs8</geDBID2000>
        <geOldRidListID2000>3775</geOldRidListID2000>
        <geDoneURLID2000>112</geDoneURLID2000>
      <gridData2000>t~~!~^4~~!~^6~~!~^e~~!~^2\nt~~!~^5~~!~^6~~!~^x~~!~^3\nt~~!~^2~~!~^7~~!~^s~~!~^4\n</gridData2000>
    </qdbapi>

    Believe it or not, all the grid edit changes are encoded within this XML which can be parsed with script and changes logged to additional fields via AJAX calls.


  • 6.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 10-03-2016 20:39
    Hmm.  I'm happy to know that it's possible, although I'll admit my experience with JS/AJAX is a bit limited.  I have had some success with the IOL technique, though, and have a decent programming background, so I might be able to figure it out.  Do you know if there is any sort of documentation for how the grid edit changes are encoded?


  • 7.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 10-03-2016 21:15
    The documentation can be found here:

    https://quickbase.intuitcdn.net/res/72799-10/js/gridEdit.js

    Use this documentation viewer:

    http://jsbeautifier.org/

    Then look for the GeditSubmit function and redefine it to suit your needs along with  a lot of console.logs():

    function GeditSubmit(dbid) {
      if (!gGED.HasDataChanged() && !gAndDone) {
        QBalert("<div class=redhead>Nothing to save.</div>You haven't made any changes.");
        return
      }
      if (!GE_validate(gGED)) {
        return
      }
      ClearErrors();
      HidePopupDiv();
      QBbusy("Saving . . .");
      var jax = new jaxreq(dbid + "?a=QBI_GridEditSubmit");
      console.log(JSON.stringify(gGED));
      GE_AddGeInfoToJax(gGED, jax);
      jax.DoAsyncCmd(GESubmitCallback)
      console.log(JSON.stringify(jax.params));
    }

    You can redefine any QuickBase authored function by injecting a modified function of the same name using IOL.

    QuickBase makes heavy use of encoded strings that are delimited by multi character separator strings (in this case "~~!~^" is a five character separator string):

    1~~!~^3~~!~^4~~!~^5~~!~^6~~!~^2~~!~^-10~~!~^-11~~!~^-12~~!~^-13

    If you decode these strings in the XML you can grab the rids, fids and field values of the modified/deleted records/fields and log what you need. It isn't fun but it isn't too difficult.


  • 8.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 11-05-2017 21:33
    How can I edit an individual field in grid edit once I've figured out the value I would like to add to it?


  • 9.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 11-05-2017 21:37
    That is an odd question to tack onto this thread.  I suggest that you post a new question with the complete Question.

    If I were to answer the question as posted my response would be "type in the grid edit cell, then save", so I am thinking you must have more to your question than that.


  • 10.  RE: Track Changes to a User Field - Even through Grid Edit

    Posted 11-05-2017 21:39
    I see what you mean. I used the suggestion above to track what edits occurred during the grid edit, and I want the GeditSubmit() function to add a record of those changes to a particular field. The only blocker I have is finding out how to programmatically edit the desired field from GeditSubmit()