07-21-2016 10:40 AM
I'm testing the GET endpoint History to return the top 5 histories, ordered by startTime. I've tested sorting by different fields, but in every case, including sorting ascending or descending, the data returned is always the same in the same order.
The documentation states that if the feature isn't implemented, it'll throw an exception. Since it neither works nor throws an exception, I'm hoping I'm missing something. I'll include the code below.
$.ajax({ type: "GET", url: window.location.origin + "/act.web.api/api/History?$orderBy=regarding desc&$top=5", //url: window.location.origin + "/act.web.api/api/History?$filter=contains(regarding,'Check it')", headers: { "Authorization": "Bearer " + $("#display_token").html() }, success: function (data) { for (var i in data) { var j = $("#cleared_activities_output").html(); $("#cleared_activities_output").html(j + "Regarding: " + data[i].regarding + "<br/>StartTime: " + data[i].startTime + "<br/>" + data[i].historyTypeID + "<br/>" + data[i].details + "<br/><br/>"); } }, error: function (data) { alert("Error: " + JSON.stringify(data)); } })
07-21-2016 02:30 PM
Hi,
Histories con't currently support sorting (just filtering), you can review current support for the OData link in the API documentation:
07-22-2016 06:33 AM
Thanks, Xavier. Your link leads me to a 404 error; however, on closer inspection of my copy of the documentation, I do see that sorting is not supported for History.
On a related note, I'm trying to filter by the history type id, but I get an error. It's generic, so I take it that filtering on historyTypeId isn't supported right now. Can you confirm if that's correct or not?
Thanks,
bconner26
04-10-2019 01:38 AM
Hi Xavier,
I'm also looking into filtering by History Type Description, but not sure how to achieve this. Can you please help with providing a link where related documentation/instructions for this can be found?
Many thanks,
Ritvars
05-21-2019 03:24 PM
Which version of the API are you using? Sorting is supported on all entities now as long as it is not a custom fields.
/api/history?$orderby=regarding asc&$top=5&$select=id,regarding
As far as the historyType/description query, with throw an exception, because the SDK sql doesn't include name or description in the SQL query. OData query, builds Act! filters, but sometimes Act! just does not do the joins to return the data to satisfy the query. Will add this to the backlog to see if I can fix this.
/api/history?$filter=(historyType/description eq 'some text')
You can download the latest API here:
https://www.act.com/download/download-act!-premium-v19