How to Find User Attribute by Filter Column and Key

In some cases, you may need to look up some user profile information. The 'User' object contains attributes some of which are custom (i.e. configuration based). The example below shows how you can get the value for a specific attribute based on looking up the 'Users' table for a given filter column/key combination.

For example, you can call this function from a Groovy element as follows:

  findUserAttributeByFilterKey("additionalInfo1", "loginname", "admin")

This would return the value for the "additionalInfo1" column for the user with "loginname" equal to "admin".

def findUserAttributeByFilterKey(attribute, filterColumn, filterKey) {
	def users = api.find("U", 0, api.filter(filterColumn, "=", filterKey))
	for (user in users) {
		return user.get(attribute)
	}
	return null
}