Community
Showing results for 
Search instead for 
Do you mean 
Reply

Order By for History endpoint neither sorts nor throws an exception

Copper Contributor
Posts: 56
Country: United States

Order By for History endpoint neither sorts nor throws an exception

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));
                    }
                })
Employee
Posts: 241
Country: USA

Re: Order By for History endpoint neither sorts nor throws an exception

Hi,

 

Histories con't currently support sorting (just filtering), you can review current support for the OData link in the API documentation:

https://actforweb.actops.com/Act.Web.API/OData/index 

Highlighted
Copper Contributor
Posts: 56
Country: United States

Re: Order By for History endpoint neither sorts nor throws an exception

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

New Member
Posts: 2
Country: United_Kingdom

Re: Order By for History endpoint neither sorts nor throws an exception

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

Employee
Posts: 113
Country: USA

Re: Order By for History endpoint neither sorts nor throws an exception

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

https://www.act.com/download/download-act!-premium-v20

https://www.act.com/download/download-act!-premium-v21