Show/Hide Toolbars

The following sample creates a user account record. Prerequisite to working with user records, a corresponding contact (type person) record must already exist in TeamConnect . In addition, you need to get the following information before writing an application using Web Services: the unique key of the related contact record.

Code Snippet

// this sample assumes a contact record (type person) already exists with the unique key (String) value equal to contactUniqueKey

protected UserAccountRepository userAccountRepository;

private String insertUserAccount() throws Exception {

String userAccountName = "John_Doe";

UserAccountCreate userAccount = new UserAccountCreate();

//username is a required field

userAccount.setUsername(userAccountName);

//password is a required field

userAccount.setPassword("p@ssw0rd");

//contactUniqueKey is a required field

userAccount.setContactUniqueKey(contactUniqueKey);

userAccount.setShortDescription("new user hired 10/01/2008, business administrator");

userAccount.setUserType(UserType.NORMAL);

userAccount.setActive(true);

String uniqueKey = userAccountRepository.insertUserAccount(userAccount);

return uniqueKey;

}