Post

2 followers Follow
0
Avatar

REST v2 API: can't create exception on a specific user's calendar

 

To do this in a workflow rule, using the New Item action, you set the $EventCalendar field on the Calendar Exception object to the User whose calendar you want . But there is no such column available in CalendarException when accessed from the v2 REST API:

$ curl -H "Authorization: Session ..." "https://api2.clarizen.com/v2.0/services/data/objects/CalendarException" -X PUT -d "{Name:'test', StartDate:'2018-05-23', EndDate:'2018-05-25', EventCalendar:'/User/6a7ujuur3es63ysnnx69zcz203'}"
{"errorCode":"InvalidField","message":"Entity 'CalendarException' does not contain the field 'EventCalendar'","referenceId":"266iDD2XHqoLnl4ZpSnyE"}

I've solved the problem by using a custom object (CO) and a workflow rule but I want to use our CO for something else.  Is there a way to do what I want on the command line that I'm simply overlooking?

 

Lance Luvaul Answered

Please sign in to leave a comment.

8 comments

0
Avatar

Never mind:

I realised I can make ANY object act as the CalendarException wrapper, it doesn't have to be the
Custom Object. And if I use existing fields of the types required, I don't even need new custom
fields. So now I create a specially flagged Task some of whose fields are used to populate a new
CalendarException using a workflow rule. I added a new value to the TaskType picklist field called
'Calendar Exception' to distinguish these special Tasks from the rest and made the workflow trigger
on that.

I want to automatically delete these special Tasks once they've been actioned to prevent them from
accruing, so the rule above toggles a boolean field on the special Task that triggers a second work-
flow rule to delete the Task.

No custom objects or custom fields were used, just two workflow rules, to add the ability to create
CalendarExceptions via the API

Lance Luvaul 0 votes
0
Avatar

Hi Lance, 

We should be opening the ability to create Calendar Exceptions via API in an upcoming release (hopefully before end of June).

As you detailed in your other post, there's another object "CalendarInfo" which is not open to API and makes working with Calendar Exceptions more complex than with other objects. In the Workflow rule action, that complexity is handled for you with special treatment. We should be providing examples with the release. 

David Goulden 0 votes
0
Avatar

Thanks David, I saw the announcement about improvements to the API for working with CalendarExceptions... most welcome.

However, I'm now having an issue creating appropriate date/timestamps to go with the CalendarExceptions that I create via the API.  When I specify '2018-08-01' (for example) as the StartDate, I get a CalendarException that starts on the day prior, or '2018-07-31', as seen on the users calendar.  I'm on the east coast of Australia so I suspect some problem with timezones is to blame.  But I've tried correcting for the TZ difference by specifying both '2018-07-31T14:00:00' and '2018-08-01T10:00:00' but neither makes a CalendarException that starts on the right date.

What am I doing wrong?

Lance Luvaul 0 votes
0
Avatar

Never mind David: I stopped using my "2 workflow rule hack" and instead used the new ability to directly create CalendarExceptions via the API and it worked fine

Lance Luvaul 0 votes
0
Avatar

Hi Lance

Re: repeat and end fields

No plans right now. This feature was mainly to handle individual users' leave.

Recurring items tend to be national holidays (from Groups).

Can you describe your scenario?

 

David Goulden 0 votes
0
Avatar

I'm copying staff leave records from the official University human resources system into Clarizen, and our HR system allows multi-day spans of part-time leave.  For example, I can indicate I only want to work half-days for 3 days, Tuesday 2018-01-23 to Thursday 2018-01-25, inclusive.  I could try to enter this via the API using {'StartDate': '2018-01-23T09:00:00', 'AllDay': False, 'EndDate': '2018-01-25T12:30:00', 'Name': "Leave - sync'd from HR", 'EventCalendar': '/User/...', 'WorkingDay': True} but I think that causes Clarizen to interpret the *entire* day of 2018-01-24, all 24 hours of it, as working time.  From the browser UI I can create an exception for just 2018-01-23, and make it go from 09:00 to 12:30, and then make it repeat 3 times.  There's no way to do that from the API (REST v2).

Lance Luvaul 0 votes
0
Avatar

I know I can, from the API, simply create 3 separate calendar exceptions, one for each day, and make each go from 09:00 to 12:30... but it would just be nicer if I could make a single entry with repeat/end values.

Lance Luvaul 0 votes