Class Customer

Represents a customer.

Examples

Customer c;

c.load(2); // Loads customer with ID = 2
print(c.getValue("email")); // Returns a list of all emails
c.setValue("firstname", "Bob");
c.save();

Constructors

Customer()

Initializes a new instance of the Customer class.

Declaration

Customer

Examples

Customer c;

c.load(2); // Loads customer with id = 2
print(c.getValue("email")); // Returns a list of all emails
c.setValue("firstname", "Bob");
c.save();

Methods

addEmail(String,Integer,Integer)

Adds an email to a customer.

Declaration

Void addEmail(String email, Integer extTable, Integer dbiAgentId)

Parameters

Type Name Description
String email Email address.
Integer extTable External owner of this email address as an extTable ID. extTable is a deprecated database integration called data sources.
Integer dbiAgentId External owner of this email address as a dbiAgent ID.

Returns

Type Description
Void

addEmail(String,Integer,Integer,Integer)

Adds an email to a customer with the external sorting rank.

Declaration

Void addEmail(String email, Integer externalRank, Integer extTable, Integer dbiAgentId)

Parameters

Type Name Description
String email Email address
Integer externalRank External sorting rank. (Can't be changed in the Service GUI).
Integer extTable External owner of this email address as an extTable ID. extTable is a deprecated database integration called data sources.
Integer dbiAgentId External owner of this email address as a dbiAgent ID.

Returns

Type Description
Void

checkFieldRights(String,String)

Checks if the current user has access to the field.

Declaration

Bool checkFieldRights(String field, String fieldRight)

Examples

Customer c;

c.load(3);
Bool b = c.checkFieldRights("person","read");
print(b.toString());

Parameters

Type Name Description
String field The field to check.
String fieldRight Type of access to check for - read or write.

Returns

Type Description
Bool True if the current user has access to the field; otherwise, false.

checkTableRights(String)

Use this function to see if the current user has access to this customer.

Declaration

Bool checkTableRights(String tableRight)

Examples

Customer c;

c.load(3);
Bool b = c.checkTableRights("select");
print(b.toString());

Parameters

Type Name Description
String tableRight Type of access to check for - select, update, or insert.

Returns

Type Description
Bool True if the current user has access to the customer; otherwise, false.

findExternallyFromEmail(String)

Finds an entry in the external database based on an email address.

Declaration

Bool findExternallyFromEmail(String email)

Parameters

Type Name Description
String email The email address ("alias@domain").

Returns

Type Description
Bool True if an entry is found; otherwise, false.

findExternallyFromEmail(String,Integer)

Finds an entry in the external database based on an email address and an extTable ID to limit the search to one data source.

Declaration

Bool findExternallyFromEmail(String email, Integer extTable)

Parameters

Type Name Description
String email The email address ("alias@domain").
Integer extTable Used if you want to search only one data source.

Returns

Type Description
Bool True if an entry is found; otherwise, false.

findExternallyFromKey(Integer,String)

Finds an external entry based on its primary key and table ID.

Declaration

Integer findExternallyFromKey(Integer table, String key)

Parameters

Type Name Description
Integer table The external table (ext_table.id).
String key The primary key in the external table defining the entry.

Returns

Type Description
Integer True if found; otherwise, false.

findFromAgentAndKey(Integer,String)

Finds a customer entry in the database based on the given agent ID and external key.

Declaration

Integer findFromAgentAndKey(Integer agent, String key)

Parameters

Type Name Description
Integer agent The agent ID for the external entry. Implicitly defines the external data source.
String key The primary key of the external entry.

Returns

Type Description
Integer The ID for the customer entry in the database; or -1 if not found.

findFromCellphone(String)

Finds an entry based on the cellphone.

Declaration

Bool findFromCellphone(String cellphone)

Parameters

Type Name Description
String cellphone The cellphone to lookup.

Returns

Type Description
Bool True if found; otherwise, false.

findFromEmail(String)

Find a Customer instance based on the email address.

Declaration

findFromEmail(String email)

Parameters

Type Name Description
String email The address to look up. Must be address alone (alias@domain).

Returns

Type Description
Bool True if found; otherwise, false.

getValue(String)

Returns the value of the given field of the customer.

Declaration

String getValue(String colName)

Examples

Customer c;

c.load(3);
Bool b = c.checkTableRights("select");
print(b.toString());

c.setValue("name", "Test");
print(c.getValue("name"));

Parameters

Type Name Description
String colName The customer field to get data from.

Returns

Type Description
String The value of colName.

load(Integer)

Loads the customer with the given ID.

Declaration

Bool load(Integer id)

Examples

Customer c;

print(c.load(3));

Parameters

Type Name Description
Integer id The ID of the customer to load.

Returns

Type Description
Bool True if the customer exists; otherwise, false.

loadFromAgentAndKey(Integer,String)

Loads a customer based on agent id and external key.

Declaration

Bool loadFromAgentAndKey(Integer agent, String key)

Parameters

Type Name Description
Integer agent The ID of the agent that owns this customer.
String key The external key of this customer.

Returns

Type Description
Bool True if operation was successful; false if the customer does not exist.

login()

Creates a valid login session for the current customer.

Declaration

Void login()

Returns

Type Description
Void

logout()

Logs out a customer.

Declaration

Void logout()

Returns

Type Description
Void

makeSalutation()

Creates a salutation greeting the customer.

Declaration

String makeSalutation()

Examples

Customer c;

c.load(3);
Bool b = c.checkTableRights("select");
print(b.toString());

c.setValue("name", "Test");
c.setValue("salutation", "Welcome to SuperOffice");

c.makeSalutation();

Returns

Type Description
String A salutation string.

removeEmail(String)

Removes the email address from the customer.

Declaration

Void removeEmail(String email)

Parameters

Type Name Description
String email The email address you want to remove from the customer.

Returns

Type Description
Void

removeExternalEmails(Integer,Integer)

Removes all external emails from a given source (extTable).

Declaration

Void removeExternalEmails(Integer p_0, Integer p_1)

Parameters

Type Name Description
Integer p_0
Integer p_1

Returns

Type Description
Void

save()

Saves a customer. If ID is set, the customer will be updated. Otherwise, a new customer entry will be created.

Declaration

Integer save()

Returns

Type Description
Integer The ID of the saved customer.

save(String)

Saves a customer with the source key of the StoreAndProcess consent. If ID is set, the customer will be updated. Otherwise, a new customer entry will be created.

Declaration

Integer save(String gdprSourceKey)

Parameters

Type Name Description
String gdprSourceKey The source key of the StoreAndProcess consent to set (can be found in the consent system).

Returns

Type Description
Integer The ID of the saved customer.

setValue(String,String)

Sets the given field with the given value.

Declaration

Void setValue(String field, String value)

Examples

Customer c;

c.load(3);
Bool b = c.checkTableRights("select");
print(b.toString());

c.setValue("name", "Test");
print(c.getValue("name"));

Parameters

Type Name Description
String field The field to set.
String value The value to set.

Returns

Type Description
Void

toParser(Parser)

Fills a Parser object with a Customer's values, including extra fields. The fields are prefixed with "customer.".

Declaration

Void toParser(Parser parser)

Parameters

Type Name Description
Parser parser The parser to set.

Returns

Type Description
Void