Forum Discussion

EdCadorniga's avatar
5 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
    5 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 Cover User
    5 years ago

    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.

  • 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

     

     

     

  • Tana's avatar
    Tana
    MYOB Staff
    5 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
  • Thanks for your response, Tana.

     

    I tried the query (after editing the dates) but still can't get data. One thing I noticed is that I don't have a variable for the Timesheet GUID.  How do I get that data? 

     

    Ran the queries: 

    I tried it as is after I modified the dates - nogo. 

    I also tried changing the CF_Uri with our own - nogo.

     

    ***Tried without the {Timesheet GUID} and that worked.

     

    {{company_file_uri}}/{{company_file_id}}/Payroll/Timesheet/?StartDate=2020-10-19T00:00:00&EndDate=2020-10-25T00:00:00

     

    Does this mean I can no longer apply any filter to this query? 

     

    Not sure if that should be a new question but I'll mark your response as the solution. 

     

    Thank you for your help. 

     

    Regards,

    Ed

     

  • Tana's avatar
    Tana
    MYOB Staff
    5 years ago

    Thank you for the update there.

    The URI I posted came directly from the response headers when running a GET request to /{cf_uri}/Payroll/Timesheet/{timesheet URI} (We used insomnia for this test).

    This URI automatically had the query at the end, so for us was just a matter of changing the dates and copy/pasting this URI as a standard GET request, this appears to be the only way run this query.

    The image you have pasted I would assume wouldn't work, trying to use the params wont work like that i'm afraid and can only be entered as a request.

    If you would like us to investgate this further create a support ticket here and we can run some tests using some of your details and try replicate our success.

    Kind regards
     

Looking for something else?

Search the Community Forum for answers or find your topic and get the conversation started!

Community home

Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.