Question

OData filter dynamic date range

  • 9 March 2024
  • 1 reply
  • 61 views

Badge

Hello,

I am trying to create a lobby element with a navigation for Aurena that filters the list on the navigated page based on current week. I have tried using the following filter expression:

page/MaintenanceEngineerTaskExecution/AssignmentAssigned?$filter=(AllocatedStart ge '#START_OF_THIS_WEEK#' and AllocatedStart le '#END_OF_THIS_WEEK#') and (Objstate eq IfsApp.TechPortalTaskExecution.MyAssignmentEntityState'ASSIGNED')

 

I get the following Aurena: 

{
    "error": {
        "code": "ODATA_PROVIDER_ERROR",
        "message": "An internal server error occurred. Contact administrator.",
        "details": [
            {
                "code": "TYPES_NOT_COMPATIBLE",
                "message": "The types 'Edm.DateTimeOffset' and 'Edm.String' are not compatible."
            }
        ]
    }
}

 

I have tried wrapping AllocatedStart in Date(), which gives me a similar error, Edm.Date and EdmString are not compatible. I have also tried wrapping the CSV (#START_OF_THIS_WEEK#) in Date(), and still get a similar error. Can someone offer some guidance on the right syntax to use to pull this off? This is in IFS Apps 10, so I’m not sure if the functionality between 10 and Cloud are different in terms of the OData syntax.

 

Any help would be greatly appreciated!


1 reply

Userlevel 2
Badge +4

 

The issue lies with the filter query you've written. By wrapping the date values with single quotes, they are treated as Strings. If you remove the single quotes from the date values, it should resolve the issue.

Only tested this with IFS Cloud but it is same with IFS Cloud and Apps 10 (in the backend). My main concern is whether the #START_OF_THIS_WEEK# placeholder value is replaced by the client before sending the request to the backend. If removing the single quotes still results in an error, please inspect the request made to the backend. It should not contain #START_OF_THIS_WEEK#; instead, it should have the correct date value.

 

Reply