AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. On-line marketing
  3. Accounts

Accounts


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Accounts
    • Creating an account
    • Updating accounts
    • Adding contacts to an account
    • Removing contacts from an account
    • Deleting an account
  • Account statuses
    • Creating an account status
    • Updating an account status
    • Updating multiple account statuses
    • Assigning a status to an account
    • Removing statuses from accounts
    • Deleting an account status
  • Contact roles for accounts
    • Creating a contact role
    • Updating a contact role
    • Updating multiple contact roles
    • Assigning a role to contacts in an account
    • Deleting a contact role

Accounts

Creating an account

C#
// Creates a new account object
AccountInfo newAccount = new AccountInfo()
{
    AccountName = "New Account"
};

// Saves the new account to the database
AccountInfo.Provider.Set(newAccount);
> Back to list of examples

Updating accounts

C#
// Gets all accounts whose name starts with 'New'
var accounts = AccountInfo.Provider.Get().WhereStartsWith("AccountName", "New");

// Loops through individual accounts
foreach (AccountInfo account in accounts)
{
    // Updates the account's properties
    account.AccountName = account.AccountName.ToLowerCSafe();

    // Saves the modified account into the database
    AccountInfo.Provider.Set(account);
}
> Back to list of examples

Adding contacts to an account

C#
// Gets the 'New Account' account
AccountInfo account = AccountInfo.Provider.Get()
                                            .WhereEquals("AccountName", "New Account")
                                            .TopN(1)
                                            .FirstOrDefault();

if (account != null)
{
    // Gets all contacts whose last name is 'Smith'
    var contacts = ContactInfo.Provider.Get().WhereEquals("ContactLastName", "Smith");

    // Loops through individual contacts
    foreach (ContactInfo contact in contacts)
    {
        // Creates an object representing the relationship between the account and the contact
        AccountContactInfo accountContact = new AccountContactInfo()
        {
            AccountID = account.AccountID,
            ContactID = contact.ContactID
        };

        // Saves the account-contact relationship to the database
        AccountContactInfo.Provider.Set(accountContact);
    }
}
> Back to list of examples

Removing contacts from an account

C#
// Gets the 'New Account' account
AccountInfo account = AccountInfo.Provider.Get()
                                            .WhereEquals("AccountName", "New Account")
                                            .TopN(1)
                                            .FirstOrDefault();

if (account != null)
{
    // Gets the first contact whose last name is 'Smith'
    ContactInfo contact = ContactInfo.Provider.Get()
                                        .WhereEquals("ContactLastName", "Smith")
                                        .TopN(1)
                                        .FirstOrDefault();

    // Gets the relationship between the contact and the account
    AccountContactInfo accountContact = AccountContactInfo.Provider.Get(account.AccountID, contact.ContactID);

    if (accountContact != null)
    {
        // Removes the contact from the account
        AccountContactInfo.Provider.Delete(accountContact);
    }
}
> Back to list of examples

Deleting an account

C#
// Gets the 'New Account'
AccountInfo deleteAccount = AccountInfo.Provider.Get()
                                            .WhereEquals("AccountName", "New Account")
                                            .TopN(1)
                                            .FirstOrDefault();

if (deleteAccount != null)
{
    // Deletes the account
    AccountInfo.Provider.Delete(deleteAccount);
}
> Back to list of examples

Account statuses

Creating an account status

C#
// Creates a new account status object
AccountStatusInfo newStatus = new AccountStatusInfo()
{
    AccountStatusDisplayName = "New account status",
    AccountStatusName = "NewAccountStatus",
};

// Saves the account status to the database
AccountStatusInfo.Provider.Set(newStatus);
> Back to list of examples

Updating an account status

C#
// Gets the account status
AccountStatusInfo updateStatus = AccountStatusInfo.Provider.Get("NewAccountStatus");

if (updateStatus != null)
{
    // Updates the account status properties
    updateStatus.AccountStatusDisplayName = updateStatus.AccountStatusDisplayName.ToLowerCSafe();

    // Saves the modified account status to the database
    AccountStatusInfo.Provider.Set(updateStatus);
}
> Back to list of examples

Updating multiple account statuses

C#
// Gets all account statuses whose code name starts with 'New'
var statuses = AccountStatusInfo.Provider.Get()
                                            .WhereStartsWith("AccountStatusName","New");

// Loops through individual account statuses
foreach (AccountStatusInfo accountStatus in statuses)
{
    // Updates the account status properties
    accountStatus.AccountStatusDisplayName = accountStatus.AccountStatusDisplayName.ToUpper();

    // Saves the modified account status to the database
    AccountStatusInfo.Provider.Set(accountStatus);
}
> Back to list of examples

Assigning a status to an account

C#
// Gets the 'New Account' account
AccountInfo account = AccountInfo.Provider.Get()
                                            .WhereEquals("AccountName", "New Account")
                                            .TopN(1)
                                            .FirstOrDefault();

// Gets the account status
AccountStatusInfo accountStatus = AccountStatusInfo.Provider.Get("NewAccountStatus");

if ((account != null) && (accountStatus != null))
{
    // Checks that the account doesn't already have the given status
    if (account.AccountStatusID != accountStatus.AccountStatusID)
    {
        // Assigns the status to the account
        account.AccountStatusID = accountStatus.AccountStatusID;

        // Saves the updated account to the database
        AccountInfo.Provider.Set(account);
    }
}
> Back to list of examples

Removing statuses from accounts

C#
// Gets the account status
AccountStatusInfo accountStatus = AccountStatusInfo.Provider.Get("NewAccountStatus");

if (accountStatus != null)
{
    // Gets all accounts that have the specified status
    var accounts = AccountInfo.Provider.Get().WhereEquals("AccountStatusID", accountStatus.AccountStatusID);

    // Loops through the accounts
    foreach (AccountInfo account in accounts)
    {
        // Sets the status to 'None' for each account
        account.AccountStatusID = 0;

        // Saves the updated account to the database
        AccountInfo.Provider.Set(account);
    }
}
> Back to list of examples

Deleting an account status

C#
// Gets the account status
AccountStatusInfo deleteStatus = AccountStatusInfo.Provider.Get("NewAccountStatus");

if (deleteStatus != null)
{
    // Deletes the account status
    AccountStatusInfo.Provider.Delete(deleteStatus);
}
> Back to list of examples

Contact roles for accounts

Creating a contact role

C#
// Creates a new contact role object
ContactRoleInfo newRole = new ContactRoleInfo()
{
    ContactRoleDisplayName = "New role",
    ContactRoleName = "NewContactRole",
};

// Saves the contact role to the database
ContactRoleInfo.Provider.Set(newRole);
> Back to list of examples

Updating a contact role

C#
// Gets the contact role
ContactRoleInfo updateRole = ContactRoleInfo.Provider.Get("NewContactRole");

if (updateRole != null)
{
    // Updates the contact role properties
    updateRole.ContactRoleDisplayName = updateRole.ContactRoleDisplayName.ToLowerCSafe();

    // Saves the modified contact role to the database
    ContactRoleInfo.Provider.Set(updateRole);
}
> Back to list of examples

Updating multiple contact roles

C#
// Gets all contact roles whose code name starts with 'New'
var roles = ContactRoleInfo.Provider.Get().WhereStartsWith("ContactRoleName", "New");

// Loops through individual contact roles
foreach (ContactRoleInfo role in roles)
{
    // Updates the contact role properties
    role.ContactRoleDisplayName = role.ContactRoleDisplayName.ToUpper();

    // Saves the updated contact role to the database
    ContactRoleInfo.Provider.Set(role);
}
> Back to list of examples

Assigning a role to contacts in an account

C#
// Gets the 'New Account' account
AccountInfo account = AccountInfo.Provider.Get()
                                            .WhereEquals("AccountName", "New Account")
                                            .TopN(1)
                                            .FirstOrDefault();

// Gets the contact role
ContactRoleInfo contactRole = ContactRoleInfo.Provider.Get("NewContactRole");

if ((account != null) && (contactRole != null))
{
    // Gets the relationships between the account and all of its contacts
    var accountContactRelationships = AccountContactInfo.Provider.Get().WhereEquals("AccountID", account.AccountID);

    // Loops through the contact-account relationships
    foreach (AccountContactInfo accountContact in accountContactRelationships)
    {
        // Assigns the role to the contact for the specified account
        accountContact.ContactRoleID = contactRole.ContactRoleID;

        // Saves the account-contact relationship to the database
        AccountContactInfo.Provider.Set(accountContact);
    }
}
> Back to list of examples

Deleting a contact role

C#
// Gets the contact role
ContactRoleInfo deleteRole = ContactRoleInfo.Provider.Get("NewContactRole");

if (deleteRole != null)
{
    // Deletes the contact role
    ContactRoleInfo.Provider.Delete(deleteRole);
}
> Back to list of examples