What does this script change exactly? In the gateway, we have users, and users tied to specific schedules, but not a schedule for each user per say.

If I run this script for a user, where specifically in the gateway will I see the reflected changes?

In the Designer or Client, you can see it in the UserManagement component.

In the Gateway you can see it in the internal database (if you’re using the internal user source), or in the database user source if that’s what you’re using. (e.g. it’s stored in the user source).

So I’m using this function to put a user back onto the schedule. I’m setting the third parameter of the function to True, so it should be putting the user back on the schedule, no? The function did take the user off the schedule when I had the Bool set to False.

Here’s my code:

In a designer/client, drop a User Management component onto a window. Select the user, click the “edit” button. On the edit window, scroll down to the bottom two panels, which are a list of schedule adjustments and a calendar showing when the user is and isn’t available.

This screen shot shows a schedule adjustment that I just added for a user using the example script with a couple of small modifications (which is almost identical to yours).

Hmm… I wonder if you found a bug. When I try someone who isn’t scheduled and add a schedule adjustment of True, it’s not showing up in the User Management panel. I’m going to investigate this further.

I also see you are using vision’s client? my purpose here is for building a custom screen in perspective. Regardless, it does look like both you and I are not able to make the schedule adjustment of True work.

Circling back on this topic–I wanted to share that there is a UIResponse object returned from system.user.editUser() calls that can provide some extra messaging on the result of the call. This helped me discover that you cannot use these methods to alter the gateway system user source.

Here is the tail end of my testing script:

ui_response = system.user.editUser(user_source, user)
[ for x in ui_response.getInfos()]
[logger.warn(x) for x in ui_response.getWarns()]
[logger.error(x) for x in ui_response.getErrors()]

… which produced the following error when trying to apply this to a user in the default user source (selected as the Gateway System user source by default):

13:45:31.116 [AWT-EventQueue-0] ERROR scheduling - You are not authorized to modify the Gateway system user source.

All of that said, the changes to scheduling (against a separate user source) with or without isAvailable seem to be functioning correctly at this time. While I’m in here, I’ll mention that I did have to call the updateTables() method against the Vision User Management component to have the changes I was doing via scripting reflect properly (or reload the window, thus refreshing the user/schedules implicitly).

Hope this helps!