Forum Discussion

EdCadorniga's avatar
4 years ago
Solved

Unable to get previous timesheets, only current timesheet can be retrieved

Hi, 

 

I am trying to query for past timesheets using Postman and am able to only get the current week's timesheet data (while no filter is used). 

 

This query does not work: (see screenshot below)

{{company_file_uri}}/{{company_file_id}}/Payroll/Timesheet/?$filter=StartDate eq datetime'2020-10-19' and EndDate eq datetime'2020-10-25'

 

I've also tried filtering with only the StartDate or EndDate - no success.

 

While this query works: 

{{company_file_uri}}/{{company_file_id}}/Payroll/Timesheet/ but only shows the current period's timesheets.

 

 

This seems to be the same issue as what was here: https://community.myob.com/t5/MYOB-API-questions-and-answers/Timesheets-Request-Only-Returns-Timesheets-in-the-Current-Week/td-p/370909 

 

I've already tried the solution there with no success.

 

Also, if there is some prepared query that you can share that will provide a report similar to the one we can generate through REPORTS > Timesheets, that would be awesome. 

 

Any assistance would be appreciated. 

 

Regards,

Ed

  • Tana's avatar
    Tana
    4 years ago

    Hi there.

    Thank you for reaching out and apologise for the delayed response.

    The /{cf_uri}/Payroll/Timesheet endpoint contains a query/filter by default in the URI response of your standard request.

    This query is compulsory and is what enables this area to display the timesheets in the current period without needing to have your own query to do so.

    What I recommend is copy this URI from your response and use it as a template to create the query.
    You will notice that this query isn't quite formatted like our typical Odata filters.

    Here is what it will look like:

    https://ar1.api.myob.com/accountright/36c69572-d2a7-4539-86df-5d47256d098c/Payroll/Timesheet/d6a5a299-0c4e-40f1-9a98-df1575cdf9d1?StartDate=2020-10-21T00:00:00&EndDate=2020-10-27T00:00:00"
    Edit the details/date and run your GET request using this and you will be able to display the timesheets within the date range.

    If you have any difficulty with this let me know.
    Kind regards

6 Replies

Replies have been turned off for this discussion
  • Mike_James's avatar
    Mike_James
    Ultimate Partner

    Hi EdCadorniga , for a range of timesheets, I wonder if this would work:

    $filter=StartDate ge datetime'2020-10-19' and EndDate le datetime'2020-10-25'

    or possibly this:

    $filter=StartDate ge datetime'2020-10-19 00:00:00' and EndDate le datetime'2020-10-25 23:59:59'

     

    I don't have access to any timesheet data atm, so I can't test it.

    • EdCadorniga's avatar
      EdCadorniga
      User

      Hi, Mike_James.

       

      Thanks for responding. I tested both filters and both were unsuccessful, unfortunately.  I have attached the responses I have received. 

       

      Regards,

      Ed