Record view count - Best Approach

gaidem
ServiceNow Employee
ServiceNow Employee

I'm looking to have an integer that shows how many times a record has been viewed. What's the most efficient way of achieving this?

10 REPLIES 10

Chuck Tomasi
Tera Patron

I would create a new field (e.g. u_view_count) and use a Script Action to maintain it. The script action is triggered from an event (in this case user.view). I might recommend a filter (or some intelligence in the script action) to filter when it actually updates the u_view_count field since user.view is triggered when you view just about anything on the system.

http://wiki.service-now.com/index.php?title=Script_Actions


gaidem
ServiceNow Employee
ServiceNow Employee

This works, except I don't want the count to go up if the user the ticket was opened for views it. How can I pass or create a variable in the script actions for the current user?

Thanks


gaidem
ServiceNow Employee
ServiceNow Employee

I also need to show who viewed the record and at what time. The suggested approach doesn't seem to allow this. Any ideas?


CapaJC
ServiceNow Employee
ServiceNow Employee

Use a "display" business rule. The value of the When field is "display". These run before displaying a record in a form, and you have full access to "current" and can know who the user is through various gs. methods (gs.getUserID(), etc.).

--J