Update record upon view | Discussions

Expand all | Collapse all

Update record upon view

  • 1.  Update record upon view

    Posted 02-21-2018 21:11
    I'm creating a comments table related to tasks in a PM tool. I have a checkbox field for "unread" that defaults to checked. I then have a report that shows all unread comments per user. The comment field is a truncated version of the full comment. I would like to allow the user to click the comment and view the full thing and, when they view it, have the "unread" field update itself to "read." 

    Is this possible or some other work around to get it so that the user doesn't need to do anything to update the read status of the comment?


  • 2.  RE: Update record upon view

    Top
    Contributor
    Posted 02-22-2018 16:42
    Hi Jeff,

    I have actually set something like that up in the past it just requires a little adjustment in several places. Essentially what you can do is create a formula URL button on the Comments table that Tasks are created to that will run an API_EditRecord which marks that field as "Read" and then redirects the user to the Comment. To best make this work you need to go into the report you are basing your report link off and disable the ability to edit and view the record from the report. This way your user only has the option of clicking the View Comments URL button you would create. 

    Once you have the field you would use something like the below formula:

    URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=YourAppTokenHere&rid="&[Record ID#]&"&_fid_field id of status field="& "Read" &  "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])
    This way when your users are on the Tasks table they can see the report link (based on this custom report that has the ability to edit or view a record from the report disabled) and they will click the View Comment button to open it up while the button in the background is marking your comment as read. It will look a bit like my example app below just with your needed fields in place on that report link.



  • 3.  RE: Update record upon view

    Posted 02-22-2018 17:16
    Evan, thank you for that! It was actually quite easy to implement and has now armed me with more tricks like this! I just realized, after doing this, that this will change the record no matter who views it.... Any thoughts on how to go about doing this per user? I want to use this report a bit like a notification area for each user. If more than one person is tagged on the comment, I don't one person 1 marking the comment as read for person 2.


  • 4.  RE: Update record upon view

    Top
    Contributor
    Posted 02-22-2018 18:34
    That is a very good question Jeff, that is correct that the button would mark it read by whoever read that comment first. I'm going to have to think on that next level of complexity a bit. 


  • 5.  RE: Update record upon view

    Posted 02-22-2018 19:11
    Evan, I got it figured out. I added a new field to the form called "read by". The field is a user list. Then I modified your button to pass the logged in user rather than a static flag. Then I modified the report to show all comments where the logged in user was notified and was not in the "read" list. Works like a champ!


  • 6.  RE: Update record upon view

     
    Posted 02-22-2018 19:42
    Jeff--does this account for multiple users being registered in the "read by" field? So if you were to click the button, and were added to the "read by" field, then I were to click the button--would we both end up in the "read by" field, rather than my user value overwriting yours?


  • 7.  RE: Update record upon view

    Posted 02-22-2018 19:49
    Yep. It's a User List field type and allows for multiple users to be selected. 


  • 8.  RE: Update record upon view

     
    Posted 02-23-2018 16:46