locked
Query using date parameter not working RRS feed

  • Question

  • Hi,

    I am trying to set up a view details screen that has the details of an Inspection Report entity up the top and then a table of related rows from a Maintenance Jobs entity below that. Basically, I want to show all maintenance reports that were created on the same date as the inspection report. However, when I test the screen, it never finds any entries. I have tested using a query parameter of a different type and that functions as expected. However, whenever I set the query parameter to a date and bind it to the Date field of the Inspection Report entity, I get no items. Both entities are internal to Lightswitch, so there shouldn't be any differences in the formatting between the two fields. All the examples I have been able to find involve queries with minimum and maximum date parameters, so I am wondering if there is an issue trying to search for a specific Date.

    Update - I have since tried with filters using less than dates and still no results, so something must not be quite right somewhere.

    Thanks,

    Alan


    • Edited by alanuhe Tuesday, November 4, 2014 7:08 AM
    Tuesday, November 4, 2014 3:37 AM

Answers

  • Ok, I have managed to finally solve this one. The issue was with my code that was bound to a field of Date type. The value assignment was basically assigning a string instead of a new Date object, which was meaning that the query couldn't work out what to do with it. So it was a format issue but of a different sort.

    Avatarku, thanks for your assistance.

    • Marked as answer by alanuhe Wednesday, November 5, 2014 5:39 AM
    Wednesday, November 5, 2014 5:39 AM

All replies

  • Wednesday, November 5, 2014 2:30 AM
  • Thanks for the reply.

    I probably should have mentioned earlier that this is a Cloud Business App, so running against Sharepoint Online in case that makes a difference.

    I have done some more testing and found the following: Queries work against globals as exepected but not against parameters. I have used Moment to force the format of the local property bound to the parameter to use an Australian date format as well as a US one and neither makes a difference.

    I'm thinking that there may be a solution in forcing the property to use the same format as the globals do because they actually seem to work but not sure where the difference is to change.

    I'm not sure what to do with your links specifically to fix the issue though. I had come across that MSDN article before but it didn't really give me anything.

    Thanks.

    Wednesday, November 5, 2014 2:48 AM
  • Ok, I have managed to finally solve this one. The issue was with my code that was bound to a field of Date type. The value assignment was basically assigning a string instead of a new Date object, which was meaning that the query couldn't work out what to do with it. So it was a format issue but of a different sort.

    Avatarku, thanks for your assistance.

    • Marked as answer by alanuhe Wednesday, November 5, 2014 5:39 AM
    Wednesday, November 5, 2014 5:39 AM