SWS CreateNewAccount Method
Creates an account and a primary contact, including addresses and phone numbers for the account/contact.
Parameters
Name | DataType | Is Required |
---|---|---|
OrgID | Long | Required |
Description | The organization’s ID number. | |
SiteID | Long | Required |
Description | The site’s ID number. This can be found using the GetSiteList method. | |
FirstName | String | Required |
Description | The first name of the primary contact on the account. | |
LastName | String | Required |
Description | The last name of the primary contact on the account. | |
AccountName | String | Optional* |
Description | The name on the account. This may differ from the primary contact’s name in some instances, such as a business account or a guardianship account. Max string length of 150. *Required if this is a business account. The Account Name will reflect the business and the contact name will be for the specific contact. If this is a personal account, the account name will be inferred as the contacts last name, first name. |
|
AccountClass | AccountClass | Required |
Description | The class of the account. Available values:
|
|
ContactType | ContactType | Required |
Description | The type of account. Most users should be set as ACCOUNT_MANAGER. Available values:
|
|
String | Optional | |
Description | The email where the customer would like to receive correspondence. This also acts as the username if the site supports eStore/eCommerce. Max string length of 100. | |
ContactAddress | ContactAddress | Required |
Description | The object containing the required information for the contact’s address record. | |
ContactPhone | ACCT_CONTACT_PHONE | Required |
Description | The object containing the required information for the contact’s phone number record. | |
EcommCode | String | Optional |
Description | The rental contact’s alpha-numeric password/eCommerce code. Defining this parameter will automatically register the customer for eStore/eCommerce. | |
BLACKLIST_SMS | Boolean | Optional |
Description | Sets the customer to allow SMS text messages to their phone (“False”) or removes their number from the SMS list (“True”). Defaults to “False”. If they are added on one account it will apply to all the accounts with their phone number at the organization. |
Returned Parameters
Name | DataType |
---|---|
AccountID | Long |
Description | The account’s ID number. |
ContactID | Integer |
Description | The rental contact’s ID number. |
Addresses | ACCT_CONTACT_ADDRESSES |
Description | The object containing the contact’s address information. |
Phones | ACCT_CONTACT_PHONES |
Description | The object containing the contact’s phone information. |
Example
As with every method we need to pass in credentials. We do this with the LookupUser request object.
We’ll assume you’ve got a web reference, let’s name it SWS, in your Visual Studio project. At this point we need to our objects. We’ll need the standard service object, a CreateNewAccount request object and a CreateNewAccount response object. We can define and create these like this:
// Create request and response objects
SWS.WSSoapClient service = new SWS.WSSoapClient();
SWS.CreateNewAccount_Request request = new SWS.CreateNewAccount_Request();
SWS.structCreateAccount response;
SWS.ContactAddress address = new SWS.ContactAddress();
SWS.ACCT_CONTACT_PHONES phone = new SWS.ACCT_CONTACT_PHONES();
Here’s my sample code of the Request object.
// new address object address.Addr1 = "1234 Main St"; address.Addr2 = "Apt. B"; address.City = "My Town"; address.State = "UT"; address.PostalCode = "55555"; address.Country = "USA"; address.AddrType = SWS.AddressType.HOME; address.Active = true; // new phone object phone.PHONE = "800-555-1212"; phone.PHONE_TYPE = SWS.PhoneType.MOBILE; // new acct request request.OrgID = 123456; request.SiteID = 123456; request.FirstName = "FirstName"; request.LastName = "LastName"; request.AccountName = "LastName, FirstName"; request.AccountClass = SWS.AccountClass.PERSONAL; request.ContactType = SWS.ContactType.ACCOUNT_MANAGER; request.Email = "email@co.com"; request.EcommCode = "mypassword"; request.ContactAddress = new SWS.ContactAddress[]{ address}; request.ContactPhone = new SWS.ACCT_CONTACT_PHONES[] { phone };
Finally we can call the method and pass across the login object and the request object to create our new account. It’s a good idea to do this in a Try Catch block.
Try // Call the method that will load the response object try { response = service.CreateNewAccount(user_request, request); } catch (Exception ex) { MessageBox.Show(ex.Message); }
Note that if something goes wrong the service will respond with an exception. You’ll want to take a look at that message returned in that exception so it can be debugged.
For a full list of methods see SWS Methods.
-
July 1, 2013 at 5:24 pmSWS CreateNewAccount and AddNewContact methods now validate string parameters correctly | Centershift Developer eXchange