Add "Updated_at" Use for API

Idea created by Ivan Armendariz on Jun 8, 2017
    New Idea
    Score35
    • Brad Bateman
    • Andrew Fisher
    • Bernard Welmers
    • Gustavo Trujillo
    • Mark Rottman
    • Cameron Tipton
    • Ivan Armendariz

    Let me start of by saying that this is closely tied to the existing question and feature requests here:

     

    Filters based on 'Updated At' 

     

    Allow filtering on 'Updated_At' 

     

    We would really like it if we could also add this attribute to the API so that we can also use the filter there. We're currently more concerned about getting this added to the user objects, but some of the objects in the system such as computers, incidents, etc already have some variant of this data but is not filterable. Preferably, we would like the Update_At (Time Stamp) added to the objects that don't already have it and allow them to be filtered both on the site and via the API.

     

    For anyone interested in a workaround keep reading.

     

    In the mean time, we created a custom date/time field and added it to the User form. Under normal circumstances, this field would have to be set manually if you're still managing your Samanage user accounts manually. If you're managing them with the API however, you simply need to change this field every time you edit something in the account.

     

    If you take a look at the API documentation you won't find a lot of information regarding how to format this custom date/time field when setting it or getting it from Samanage. After some poking, I managed to come up with the following:

     

    *Note - The name of my custom field is "Last Modified"

     

    How to set

     

    URI Example: https://api.samanage.com/users/USER_ID.json

     

    REST Method: PUT

     

    Headers: “Accept=application/vnd.samanage.v1.1+json” “Content-Type=application/json”

     

    Body:

    {

       "user":{

          "custom_fields_values":{

             "custom_fields_value":[

                {

                   "value":"Jun 07, 2017 -  8:00AM",

                   "name":"Last Modified"

                }

             ]

          }

       }

    }

     

    Date/Time Format: {First 3 letters of month name} {Full month numeric}, {Full year} – {Hour}:{Minutes}{AM||PM} e.g. Jun 07, 2017 -  8:00AM

     

    How to get

     

    URI Example: https://api.samanage.com/users.json?Last+Modified%5B%5D=Select+Date+Range&&Last+Modified_custom_gte%5B%5D=2017-06-06T05:37:00&Last+Modified_custom_lte%5B%5D=2017-06-06T06:00:00

     

    REST Method: GET

     

    Headers: “Accept=application/vnd.samanage.v1.1+json” “Content-Type=application/json”

     

    Date/Time Format: {Full year}-{Full month}-{Full day}T{Full hour}:{Full minutes}:{Full seconds} e.g. 2017-06-06T05:37:00

     

    Here is the only catch I’ve noticed with this workaround so far, the server time is off by 4 hours PST. So if you’re looking for something that was last modified at 8:00AM PST, you would have to ask it to start looking at 4:00AM PST. I also haven’t confirmed if this hour offset is static or if it varies depending on which server is feeding you the information. If anyone has more concrete formatting for this type of custom field I'd really appreciate some feedback.

     

    Thanks for the consideration.

    What problem will this feature solve?:
    https://community.samanage.com/message/7373-filters-based-on-updated-at