Skip to main content

SetUserScheduleExceptions()

Programmatically add, update or remove exceptions for a user

Written by Erik
Updated today

SetUserScheduleExceptions(mapslyUserId, exceptions[]) : adds/updates/removes exceptions for the indicated user:

  • to remove an existing exception: pass its id with no other params;

  • to update an existing exception: pass its id with the updated params;

  • to create a new exception, omit the id param while providing the remaining params.
    ​

NOTE: exceptions that are not referenced in exceptions[] by their IDs will remain unchanged.

Input

mapslyUserId: ID of a user for whom you want to retrieve information.
OR

mapslyUserId[]: array of IDs of users for whom you want to retrieve information

exceptions[]: array containing objects with exceptions

Example #1: creating an exception (for holidays):

{{ SetUserScheduleExceptions(currentMapslyUser.userId.system, [
{
"periodFrom": "2026-05-10T20:00:00.000Z",
"periodTo": "2026-05-18T19:59:59.999Z",
"workingHours": {
"monday": null,
"tuesday": null,
"wednesday": null,
"thursday": null,
"friday": null,
"saturday": null,
"sunday": null
},
"allowedOvertime": null,
"breakType": null,
"breakDuration": null,
"breakEarliestTime": null,
"breakLatestTime": null,
"breakMaxDrivingTime": null,
"startPoint": null,
"endPoint": null
}
]) }}

Example #2: deleting an exception:

{{ SetUserScheduleExceptions(currentMapslyUser.userId.system,
[
{
"id": "89b41b89-bb6a-471e-94ef-b8ab833ce8b9"
}
]
)
}}

Example #3: updating 2 exceptions:

{{ SetUserScheduleExceptions(currentMapslyUser.userId.system,
[
{
"id": "89b41b89-bb6a-471e-94ef-b8ab833ce8b9",
"periodFrom": "2026-04-27T20:00:00.000Z",
"periodTo": "2026-04-30T19:59:59.999Z",
"workingHours": {
"monday": null,
"tuesday": {
"start": {
"hours": 9,
"minutes": 0
},
"end": {
"hours": 14,
"minutes": 0
}
},
"wednesday": { },
"thursday": { },
"friday": null,
"saturday": null,
"sunday": null
},
"allowedOvertime": null,
"breakType": null,
"breakDuration": null,
"breakEarliestTime": null,
"breakLatestTime": null,
"breakMaxDrivingTime": null,
"startPoint": null,
"endPoint": null
},
{
"id": "4b6b5cb9-5c3f-47f7-9c31-c3b78ce4c4b4",
"periodFrom": "2026-05-10T20:00:00.000Z",
"periodTo": "2026-05-18T19:59:59.999Z",
"workingHours": {
"monday": null,
"tuesday": null,
"wednesday": null,
"thursday": null,
"friday": null,
"saturday": null,
"sunday": null
},
"allowedOvertime": null,
"breakType": null,
"breakDuration": null,
"breakEarliestTime": null,
"breakLatestTime": null,
"breakMaxDrivingTime": null,
"startPoint": null,
"endPoint": null
}
]
)
}}
Did this answer your question?