Set User Properties through Scripting

I’m trying to set a user’s badge ID through scripting. I’ve tried this, but it does not work… any suggestions on what I’m missing?

def updateUserBadge(userSource,userName,badgeNumber="1234567"):
	# Retrieve the user we're going to edit.
	userToChange = system.user.getUser(userSource, userName)
	system.user.editUser(userSource, userToChange)


I’m not entirely sure here but I did run into something like this when dealing with alarm event objects. I remember having to actually create the static property being used to update the object before setting it. Someone else will probably have a better understanding of this than I but it may be worth it to look at the object structure in the java docs here: PyUser

What type of usersource are you using?

I’m using an AD\Internal hybrid.

Issue is resolved - it turns out that that you can only call it from a gateway scope, not from a client script.

1 Like