AccountUser
Core library AccountUser — manage users in the business unit (init, add, retrieve, update, activate, deactivate).
AccountUser manages Marketing Cloud users in the account: creating users, querying them, updating profile fields, and activating or deactivating a user. User records cannot be deleted via SSJS — use Deactivate as the removal path.
Requires Platform.Load("core", "1.1.5") before use.
Methods
| Method | Returns | Description |
|---|---|---|
AccountUser.Init(targetUserKey, myClientID) |
AccountUserInstance | Bind to a user by key and MID |
AccountUser.Add(properties) |
string | Create a user |
AccountUser.Retrieve(filter) |
object[] | Query users |
<AccountUserInstance>.Update(properties) |
string | Update the initialized user |
<AccountUserInstance>.Activate() |
string | Activate the user |
<AccountUserInstance>.Deactivate() |
string | Deactivate the user |
AccountUser.Init
Initializes an AccountUser instance bound to the given user external key and business unit MID.
Syntax
AccountUser.Init(targetUserKey, myClientID)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
targetUserKey |
string | Yes | External key of the user |
myClientID |
number | Yes | MID of the business unit |
Return value
AccountUserInstance
Examples
Platform.Load("core", "1.1.5");
var acctUser = AccountUser.Init("myAccountUser", 123456789);
AccountUser.Add
Creates a new Marketing Cloud user with the specified properties.
Syntax
AccountUser.Add(properties)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
properties |
object | Yes | User fields (Name, UserID, Password, Email, ClientID, DefaultBusinessUnitKey, AssociatedBusinessUnits, …) |
Return value
"OK" on success.
Examples
Platform.Load("core", "1.1.5");
var newUser = {
Name: "Andrea Cruz",
UserID: "acruz",
Password: "insert new password here",
Email: "acruz@example.com",
ClientID: 123456789,
DefaultBusinessUnitKey: "childBUKey",
AssociatedBusinessUnits: ["childBUKey", "grandchildBUKey"]
};
var status = AccountUser.Add(newUser);
AccountUser.Retrieve
Retrieves user records matching the given filter criteria.
Syntax
AccountUser.Retrieve(filter)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
filter |
object | Yes | Search criteria |
Return value
object[]
Examples
Platform.Load("core", "1.1.5");
var accountUser = AccountUser.Retrieve({
Property: "CustomerKey",
SimpleOperator: "equals",
Value: "MyAccount"
});
<AccountUserInstance>.Update
Updates the initialized user’s profile with the given properties.
Syntax
<AccountUserInstance>.Update(properties)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
properties |
object | Yes | Fields to change |
Return value
"OK" on success.
Examples
Platform.Load("core", "1.1.5");
var acctUser = AccountUser.Init("myAccountUser", 123456789);
var status = acctUser.Update({ Password: "XXXXX" });
<AccountUserInstance>.Activate
Activates the initialized user account.
Syntax
<AccountUserInstance>.Activate()
Return value
"OK" on success.
Examples
Platform.Load("core", "1.1.5");
var acctUser = AccountUser.Init("myAccountUser", 123456789);
var status = acctUser.Activate();
<AccountUserInstance>.Deactivate
Deactivates the initialized user. Account users cannot be deleted via SSJS; deactivation is the supported “offboarding” path.
Syntax
<AccountUserInstance>.Deactivate()
Return value
"OK" on success.
Examples
Platform.Load("core", "1.1.5");
var acctUser = AccountUser.Init("myAccountUser", 123456789);
var status = acctUser.Deactivate();