User Management Component: Pre-populate notes

Is there a way to use the onCreateUser extension function to pre-populate the user notes in the user management component?

Not from onCreateUser, but you should be able to from onSaveUser, by modifying the provided user parameter. Something like:

	from com.inductiveautomation.ignition.common.user.User import Notes
	user.set(Notes, "Some notes")

Actually, I wanted to pre-populate the notes with keys and the user would fill in the values for those keys where onSaveUser would parse and run logic based on values. Sort of hacky way of adding more user fields to the management tool.

Hmm, I’m not seeing any real ways to do that, either…

In theory, you could do something with the customProps field that’s exposed for custom user properties added by third party module authors; this doesn’t work, but it should be something like this:

	from java.lang import String
	from com.inductiveautomation.ignition.common.config import BasicConfigurationProperty
	from org.apache.commons.lang3.reflect import FieldUtils, MethodUtils
	prop = BasicConfigurationProperty("custom", "key", "categoryKey", String)
	prop2 = BasicConfigurationProperty("custom2", "key2", "categoryKey2", String)
	userEdit = FieldUtils.readField(self, "userEdit", True) 
	userEdit.setUserProps([prop, prop2])

If it worked, you’d get proper UI for each custom property in the actual user management panel.
Unfortunately, it…doesn’t work, and I’m not sure why; setUserProps is a method on the UserEdit internal class; I suspect it might be something with Jython’s automagic method discovery.

1 Like