Show/Hide Toolbars

The following sample updates an existing user account record by changing the password, changing the user type, and inactivating the user account.

Note: In actual business usage, if you are inactivating a user account, it is unlikely you would need to change other properties but the samples are provided for you to use as necessary.

Code Snippet

// this sample assumes a user record already exists with the unique key (String) value equal to uniqueKey

protected UserAccountRepository userAccountRepository;

public void test_updateUserAccount() throws Exception {

UserAccountUpdate userUpdate = new UserAccountUpdate();

//set the uniqueKey with the String value of the target user record to identify which record you are updating

userUpdate.setUniqueKey(uniqueKey);

//update the existing password

userUpdate.setPassword("newP@ssw0rd");

//update the existing userType

userUpdate.setUserType(UserType.LIMITED);

//inactive the user account

userUpdate.setActive(false);

userAccountRepository.updateUserAccount(userUpdate);

}