Post

2 followers Follow
0
Avatar

API: Update working hours in user's calendar or partial time off

Hello guys,
I am writing an integration using Clarizen API and I can mark the entire day as "non working" using Calendar Exceptions objects.
Now we also have a need to set only part of the day as "non-working", if a user had to take half a day off for example.
In the UI we can mark only part of the day as working.
The way the UI works is that you need to define the number of working days on a given day, and not "number of hours off".
How would I implement this using API?
From what I can tell in the available fields for the Calendar Exception Type you can set WorkingDay to True and AllDay to False. Now how would I provide the number of hours that user can work?
I am thinking of a simple "8 - requested hours off" kinda thing, but which parameter would I use?

I hope this makes sense.
Thank you

Anton Liubchenko Answered

Please sign in to leave a comment.

3 comments

0
Avatar

Hello Anton,

Here's the CalendarException entity description where you can see all possible fields:

{
    "entityDescriptions": [
        {
            "typeName": "CalendarException",
            "fields": [
                {
                    "referencedEntities": [
                        "User"
                    ],
                    "name": "CreatedBy",
                    "type": "Entity",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "ReferenceToObject",
                    "label": "Created By",
                    "defaultValue": {
                        "id": "/User/5iud9lre7cfpilbalaailivkt3",
                        "DisplayName": "Rolandas Pumputis"
                    },
                    "system": true,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "EntityFieldDescription"
                },
                {
                    "name": "CreatedOn",
                    "type": "DateTime",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "Date",
                    "label": "Created On",
                    "system": true,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "referencedEntities": [
                        "User"
                    ],
                    "name": "LastUpdatedBy",
                    "type": "Entity",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "ReferenceToObject",
                    "label": "Last Updated By",
                    "defaultValue": {
                        "id": "/User/5iud9lre7cfpilbalaailivkt3",
                        "DisplayName": "Rolandas Pumputis"
                    },
                    "system": true,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "EntityFieldDescription"
                },
                {
                    "name": "LastUpdatedOn",
                    "type": "DateTime",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "Date",
                    "label": "Last Updated On",
                    "system": true,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "ExternalID",
                    "type": "String",
                    "filterable": true,
                    "sortable": true,
                    "maxLength": 40,
                    "presentationType": "Text",
                    "label": "External ID",
                    "defaultValue": "3g4sxb1lve6ftq4aoxvu2vj0e19490",
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "Name",
                    "type": "String",
                    "filterable": true,
                    "sortable": true,
                    "maxLength": 512,
                    "presentationType": "Text",
                    "label": "Name",
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "WorkingDay",
                    "type": "Boolean",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "Checkbox",
                    "label": "Is Working",
                    "defaultValue": true,
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "LastUpdatedBySystemOn",
                    "type": "DateTime",
                    "filterable": false,
                    "sortable": true,
                    "presentationType": "Date",
                    "label": "System Last Updated On",
                    "system": true,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": false,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "StartDate",
                    "type": "Date",
                    "filterable": false,
                    "sortable": true,
                    "presentationType": "Date",
                    "label": "Start date",
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "EndDate",
                    "type": "Date",
                    "filterable": false,
                    "sortable": true,
                    "presentationType": "Date",
                    "label": "End date",
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "name": "AllDay",
                    "type": "Boolean",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "Checkbox",
                    "label": "Is All Day",
                    "defaultValue": false,
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "FieldDescription"
                },
                {
                    "referencedEntities": [
                        "ExceptionType"
                    ],
                    "name": "ExceptionType",
                    "type": "Entity",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "PickList",
                    "label": "Exception Type",
                    "defaultValue": {
                        "id": "/ExceptionType/Personal",
                        "Name": "Personal"
                    },
                    "system": false,
                    "calculated": false,
                    "nullable": false,
                    "createOnly": false,
                    "updateable": true,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "EntityFieldDescription"
                },
                {
                    "referencedEntities": [],
                    "name": "EntityType",
                    "type": "Entity",
                    "filterable": false,
                    "sortable": true,
                    "presentationType": "ReferenceToObject",
                    "label": "Item Type",
                    "system": true,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": false,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "EntityFieldDescription"
                },
                {
                    "referencedEntities": [
                        "Organization",
                        "User",
                        "UserGroup",
                        "Project"
                    ],
                    "name": "EventCalendar",
                    "type": "Entity",
                    "filterable": true,
                    "sortable": true,
                    "presentationType": "ReferenceToObject",
                    "label": "Event Calendar",
                    "system": false,
                    "calculated": false,
                    "nullable": true,
                    "createOnly": true,
                    "updateable": false,
                    "internal": false,
                    "custom": false,
                    "visible": true,
                    "decimalPlaces": 0,
                    "_type": "EntityFieldDescription"
                }
            ],
            "validStates": [],
            "label": "Calendar Exception",
            "labelPlural": "Calendar events",
            "displayField": "ExternalID"
        }
    ]
}
 
I have not tested this myself, but have you tried updating StartDate and EndDate fields?
 
Thank you,
Roland
Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Roland, as far as I can see StartDate and EndDate are "Date" data type, which does not take "time" information.

I will try feeding it datetime instead of simple Date, let's hope this way we can mark part of the day as "working" and not the full day.

Anton Liubchenko 0 votes
Comment actions Permalink
0
Avatar

Despite the documentation, feeding the start and end dates with datetime did the trick.

data = {'entity':
{'Id': '/CalendarException',
'Name': 'Time off',
'WorkingDay': True,
'StartDate': '2021-05-05T09:00:00.0000000',
'EndDate': '2021-05-05T12:00:00.0000000',
'AllDay': False,
'EventCalendar': userid
},
'fields': []}
Anton Liubchenko 0 votes
Comment actions Permalink