Search

User Manual

GETTING STARTED


MODULES AND PLATFORM


APPENDIX


TUTORIALS & HELPFUL TRICKS


GLOSSARY


STRATEGIC PARTNER LINKS

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

RESOURCES

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

ALL USER MANUAL VERSIONS

Ignition 8.1
Ignition 7.9
Ignition 7.8

Deprecated Pages

Skip to end of metadata
Go to start of metadata


The following feature is new in Ignition version 8.0.3
Click here to check out the other new features
This function is used in Python Scripting.

Description

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.

Syntax

system.user.getNewUser(userSource, username)

  • Parameters

String userSource - The name of the user source in which to create a user.

String username - The username for the new user. Does not check if username already exists or is valid.

  • Returns

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

  • Scope

Gateway, Vision Client, Perspective Session


Code Examples
Code Snippet
# Get new user
userToGet = system.user.getNewUser("AcmeWest", "mTrejo")

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

# Adds a user to the the AcmeWest usersource.
system.user.addUser("AcmeWest", userToGet)
Code Snippet
 # util for printing the reposonses
def printResponse(responseList):
    if len(responseList) > 0:
        for response in responseList:
            print "", response
    else:
        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", "naomi@roci.com")
 
#we can add a lot of contact info
contactInfo = {"email":"ignition_user@mycompany.com","sms": "5551212"}
user.addContactInfo(contactInfo)
 
# 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
user.addRole("mechanic")
 
# we can add a lot of roles
roles = ["Administrator", "prisoner"]
user.addRoles(roles)
 
# and we can remove a role
user.removeRole("prisoner")
 
# we can add a schedule adjustment too
date2 = system.date.now()
date1 = system.date.midnight(date2)
user.addScheduleAdjustment(date1, date2, False, "An adjustment note")
 
# we can make a bunch of adjustments and add them en-masse
date3 = system.date.addDays(date2, -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 need to save our new user and print responses
response = system.user.addUser("", user)
 
warnings = response.getWarns()
print "Warnings are:"
printResponse(warnings)
  
errors = response.getErrors()
print "Errors are:"
printResponse(errors)
  
infos = response.getInfos()
print "Infos are:"
printResponse(infos)
Keywords

system user getNewUser, user.getNewUser

  • No labels