Legacy Dev Forum Posts

 View Only

Sign Up

Insert Activity code in existing schedule

  • 1.  Insert Activity code in existing schedule

    Posted 06-05-2025 18:26

    Jeremy_MONZO | 2023-05-10 08:14:08 UTC | #1

    Hello, Currently to update a WFM schedule with a specific activity code in a particular timeframe we use these API :

    1/Create the timeoff request with a specific status (pending approved) POST /api/v2/workforcemanagement/managementunits/{managementUnitId}/timeoffrequests

    2/Update time off request. PATCH/api/v2/workforcemanagement/managementunits/{managementUnitId}/users/{userId}/timeoffrequests/{timeOffRequestId}

    The only way to update existing WFM schedule is to create an activity code as a timeoff?

    thanks


    brian.trezise | 2023-05-10 13:19:19 UTC | #2

    There is no api route to automatically apply time off requests, instead you have to apply the time off requests to the schedule and go through the update process, documented here https://developer.genesys.cloud/useragentman/workforcemanagement/upload-update-schedule

    Alternately, you can run a rescheduling operation: POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/{scheduleId}/reschedule

    and get the result when complete from this API: GET /api/v2/workforcemanagement/businessunits/{businessUnitId}/scheduling/runs/{runId}/result

    This will help to re-optimize the schedule taking the time off requests into account, but you still have to apply the suggested changes to the schedule via the update process mentioned above. Note: you can only have one un-applied reschedule per business unit at any given time. Once you're done with the reschedule result (whether you accept or decline the changes) you need to call this route to clear it: PATCH /api/v2/workforcemanagement/businessunits/{businessUnitId}/scheduling/runs/{runId}


    brian.trezise | 2023-05-10 13:26:17 UTC | #3

    Basically the principle is there is no automated process to forcibly update a schedule once created. All operations allow the customer to review changes before they're applied.


    Jeremy_MONZO | 2023-05-10 15:14:38 UTC | #4

    Hi Brian,

    Thanks for your details explanation! I can reuse this code below for update the schedule with a activityCodeId different to the timeoff activitycodeID (for example 3 for the meeting) and follow the steps described in the help.

    
    {
       "metadata":{
         "version":1
       },
       "agentSchedules":[
         {
            "userId":"00000000-0000-0000-0000-00000000000",
           "shifts":[
               {
                "id": "22222222-2222-22222-2222-222222222222",
                  "activities":[
                     {
                        "activityCodeId":"3",
                      "startDate":"2023-05-25T07:20:00.000Z",
                        "lengthMinutes":120,
                       "description":"",
                        "paid":true
                      }
                 ],
                 "manuallyEdited":true
              }
          ],
           "fullDayTimeOffMarkers":[
    
             ],
            "metadata":{
                "version":1
            }
        }

    thanks


    brian.trezise | 2023-05-10 15:26:56 UTC | #5

    Glad to help! Feel free to reach out if you have more questions


    Jeremy_MONZO | 2023-05-23 09:41:20 UTC | #6

    Hello, I have followed the guideline : https://developer.genesys.cloud/useragentman/workforcemanagement/upload-update-schedule It work perfectly if I want update one day in a schedule (for exemple Monday) but if I want update another day (ex : Wednesday) and redo the same procedure for the same week, it doesn't work. Is there limitation with this procedure to only one update for one schedule or is there something to change for the second update? thanks jeremy


    brian.trezise | 2023-05-23 14:18:14 UTC | #7

    Can you expand on what you mean by "it doesn't work"? Do you get an error message? Just taking a stab at a possible "gotcha", note that each time you save an edit to an agent's schedule you have to pull the "version" off of the response and populate it in the next update. Alternately, you can change everything you want to change in a single request


    Jeremy_MONZO | 2023-05-23 15:10:04 UTC | #8

    Hi Brian,

    From the API output, I have no errors when I run the API (but there is no modification in the WFM schedule). Just taking a stab at a possible "gotcha", note that each time you save an edit to an agent's schedule you have to pull the "version" off of the response and populate it in the next update. => I have done a simple test, the only modifications are reported is the json file with new change in the week day, is there another API (not mention in the guideline) to use for pull the "version" off the response? I cannot update everything in one time because the shift change can happen twice a day/week.

    thanks for your help jeremy


    brian.trezise | 2023-05-23 15:18:45 UTC | #9

    The error would come via the metadata from the operation completion notification (note I believe there are two ways to subscribe to events via the sdk, one of which returns notification metadata and the other does not. For debugging schedule issues you'll need the one that returns the metadata). The errors that are delivered via that notification should help you debug.


    Jeremy_MONZO | 2023-05-23 16:48:26 UTC | #10

    you mean this notification topic v2.workforcemanagement.businessunits.{id}.schedules I retrieve this log when it fails, this can be help for debug with operationId?

    { "status": "Error", "operationId": "786f58c5-c53e-441f-b819-9ab2a5a10e1b", "eventType": "Update" } thanks


    brian.trezise | 2023-05-23 17:53:08 UTC | #11

    that's the correct notification, but looks like it's the non-metadata version. I'm not super familiar with the SDK, but take a look at your notification listener. Whenever you get the event, in addition to getting the event body there should be a method to get the event metadata. The error information will be present on the metadata.


    system | 2023-06-23 17:53:39 UTC | #12

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 19833