Skip to main content
Version: 8.1


This function is used in Python Scripting.


Creates a new user object. The user will not be added to the user source until addUser is called.

Client Permission Restrictions

Permission Type: User Management

Client access to this scripting function is blocked to users that do not meet the role/zone requirements for the above permission type. This function is unaffected when run in the Gateway scope.


system.user.getNewUser(userSource, username)


StringuserSourceThe name of the user source in which to create a user.
StringusernameThe username for the new user. Does not check if the username already exists or is valid.


User - The new user, as a User object. Refer also to the PyUser class.


Gateway, Vision Client, Perspective Session

Code Examples

Example #1
# Get new user.
userToGet = system.user.getNewUser("AcmeWest", "mTrejo")

# Add some contact info.
contactInfo = {"email":"","sms": "5551234"}
userToGet.set("password", "mypassword")

# Adds a user to the AcmeWest usersource.
system.user.addUser("AcmeWest", userToGet)
Example 2
# Util for printing the responses.
def printResponse(responseList):
if len(responseList) > 0:
for response in responseList:
print "", response
print " None"

# Make a brand new 'blank' user. Not saved until we, well, save.
username = event.source.parent.getComponent('Text Field').text
user = system.user.getNewUser("", "myAwesomeUser")

# Let's fill in some fields. Note we have two ways to access property names.
user.set("firstname", "Naomi")
user.set(user.LastName, "Nagata")
user.set("password", "1234567890")

# We can add contact info one at a time. Up to the script user to make sure the type is legit.
user.addContactInfo("email", "")

# We can add a lot of contact info.
contactInfo = {"email":"","sms": "5551212"}

# We can delete contact info. Only deletes if both fields match.
user.removeContactInfo("sms", "5551212")

# We can add a role. If the role doesn't already exist, user save will fail, depending on user source.

# We can add a lot of roles.
roles = ["Administrator", "Operator"]

# We can remove a role.

# We can add a schedule adjustment too.
date2 =
date1 =
user.addScheduleAdjustment(date1, date2, False, "An adjustment note")

# We can make a bunch of adjustments and add them en-masse.
date3 =, -4)
adj1 = system.user.createScheduleAdjustment(date3, date2, True, "Another note")
adj2 = system.user.createScheduleAdjustment(date3, date1, False, "")
user.addScheduleAdjustments([adj1, adj2])

# and we can remove a schedule adjustment. All fields must match.
user.removeScheduleAdjustment(date1, date2, True, "Some other note")

# Finally, we will save our new user and print responses.
response = system.user.addUser("", user)

warnings = response.getWarns()
print "Warnings are:"

errors = response.getErrors()
print "Errors are:"

infos = response.getInfos()
print "Infos are:"