Post

4 followers Follow
0
Avatar

Update Timesheets via API

Hello,

I'm having a hard time figuring out the data model for Timesheets. By looking through the documentation I can log in, use the SessionID to become authorized and make other calls, but I can't seem to find where I can go to actually GET/PUT/POST a timesheet. 

 

Does anyone have an example of how to actually edit a timesheet to put hours down for various tasks and then submit it?

 

Thanks,

Alex

Alex Sneed Miller Answered

Please sign in to leave a comment.

12 comments

1
Avatar

Hi Alex,

I have a sample for you.

  • The first command enters the timesheet entry (use the work item and user id from your account).
  • The second command submits the entered timesheet (use the id from the result of the first command)

Curl https://api2.clarizen.com/v2.0/services/data/objects/timesheet -X PUT -d {"workitem":"/task/3pf9wh4v4vmpazrskzr2sxfuo0","reportedby":"/user/1oxqvm75aku2a8ynipdazcxk7391","duration":"4h","reportedDate":"2016-04-19"}


Curl https://api2.clarizen.com/v2.0/services/data/lifecycle -X POST -d {"ids":["/Timesheet/50rsx2mrfyhqvnpp69lf4c3tq0"],"operation":"Submit"}

Hope this helps,

Ophir

Ophir Kenig 1 vote
0
Avatar

I'm also looking for how to find the timesheet ID. When I query for timesheets I get what I think is the ID, but then I can't ever seem to figure out how to find the timesheet that is for the current week. 

Alex Sneed Miller 0 votes
0
Avatar

Hi Alex,

You probably need to check the ReportedDate field of the Timesheet entry and/or filter your query for Timesheet entries by it.

Hope this helps,

Ophir

 

Ophir Kenig 0 votes
0
Avatar

Hi Ophir,

The first command from your sample works and fills the timesheet, thank you.
The second command doesn't work (says that there's no Submit in Timesheet life cycle), but seems that we don't it as the first command already does the job.

I have another sub-question - how to set "Activity Type" and "Leave Type" fields?
I tried "activityType":"Other" but it didn't work.

Thanks.

S/S 0 votes
0
Avatar

Hi S.

I suppose the fields you mentioned are custom fields (can't find them in my account).

If I'm right you need to use their API name. Locate them in the Settings -> Configure page in Clarizen and find the API name to use.

Hope this helps,

Ophir

Ophir Kenig 0 votes
0
Avatar

Hi Alex,

Did you try using the where parameter of the query?

Hope this helps,

Ophir

Ophir Kenig 0 votes
0
Avatar

Yes, the where parameter helped me out quite a bit, thanks!

I'm still a little confused because I believe that on my web view UI I have one timesheet, but according to the API my "tasks" all seem to be part of different spreadsheets. The data model is still confusing.

Do you know where I can find documentation that shows what the other values for a timesheet besides "ReportedDate" are and what they mean? 

Alex Sneed Miller 0 votes
0
Avatar

Hi Alex,

You can find the Timesheet fields in the Settings -> Configure page (choose Timesheet on the tree view on the left), or use the metadata services to programmatically retrieve the Timesheet class and fields.

Each timesheet entry is saved as a separate object. In the Clarizen UI you may see several of them (a whole week) in a single row. That's certainly easier to work with (UX wise), but the API generally retrieves raw data so you get each separately.

Hope this helps,

Ophir

 

Ophir Kenig 0 votes
0
Avatar

Hi Ophir,

Thank you very much for all of the help.

I'm still a little confused about the timesheet data model. When I go to fill out my timesheet for the week there are 6 rows that I can put time towards each week.https://snag.gy/BQoEA2.jpg 

 

Is each row a timesheet? Or is each row a project or task? I do not see the settings button. Maybe I don't have access to it as I am not an admin?

 

Thanks,

Alex

Alex Sneed Miller 0 votes
0
Avatar

@ophir I'm trying to create and submit a Timesheet entry as per your example in this thread. I can create it alright, but when I submit it I get this error:

"[General] Submit Operation failed Reason: Method Submit is not available for Timesheet Life cycle\r\n (Reference Id: 3nlG4f3PZZn1fIXeOv8c51)"

Any idea why? Has the submission step been ditched completely since last year?

Ekin Caglar 0 votes
0
Avatar

Hi Ekin,

This error shows where submit operation is not appropriate for a timesheet entry.

My first guess would be that the approval flow in your Clarizen account (system setting 13.9) is set to 'Auto-submit and approve'. If that is the case you should use the Approve action instead of Submit.

Hope this helps,

Ophir

 

Ophir Kenig 0 votes