Skip to content

crm

const crm: {
getAccountsPage: Promise<Page<CRMAccount>>;
eachAccountsPage: Promise<void>;
getAccount: Promise<CRMAccount>;
getAddressesPage: Promise<Page<CRMAddress>>;
eachAddressesPage: Promise<void>;
getAddress: Promise<CRMAddress>;
getContactsPage: Promise<Page<CRMContact>>;
eachContactsPage: Promise<void>;
getContact: Promise<CRMContact>;
getLeadsPage: Promise<Page<CRMLead>>;
eachLeadsPage: Promise<void>;
getLead: Promise<CRMLead>;
getUsersPage: Promise<Page<CRMUser>>;
eachUsersPage: Promise<void>;
getUser: Promise<CRMUser>;
openCustomerPicker: Promise<PickerResult>;
getCurrentCustomers: Promise<Customer[]>;
getRecentCustomers: Promise<Customer[]>;
isCurrentCustomer: Promise<boolean>;
setCurrentCustomers: Promise<void>;
addCurrentCustomer: Promise<void>;
removeCurrentCustomer: Promise<void>;
clearCurrentCustomers: Promise<void>;
refresh: Promise<CRMRefreshResult>;
query: Promise<CRMQueryResult>;
};

Defined in: domains/crm.ts:33

getAccountsPage(limit, cursor?): Promise<Page<CRMAccount>>;

Get one page of CRM accounts (cursor envelope).

Requires Mobile Locker iOS 5.5.0+. Prefer crm.eachAccountsPage when walking the full set, or filter with crm.query (SOQL) when possible. Do not reassemble every page into one array for large tables (MLJS-26).

Host: GET /mobilelocker/api/crm/accounts?limit=&cursor={ data, meta: { cursor: { next, count } } } (MLI-1718). Same envelope for addresses, contacts, leads, and users.

Parameter Type Description
limit number Page size (1…5000).
cursor? string From previous meta.cursor.next. Omit for the first page.

Promise<Page<CRMAccount>>

Page of CRMAccount records.

MobileLockerError with code InvalidArgument when limit is out of range.

MobileLockerCRMError on network failure, auth expiry, or server error.

eachAccountsPage(pageSize, handler): Promise<void>;

Walk CRM accounts page by page without loading the full table into memory.

Replaces the removed getAccounts() (MLJS-26). Advances only via meta.cursor.next; stops when next === null. Prefer crm.query for filtered access. Do not push chunks into a growing array unless the set is known to be small. Requires iOS 5.5.0+.

Parameter Type Description
pageSize number Page size passed to crm.getAccountsPage (1…5000).
handler (chunk) => void | Promise<void> Called once per non-empty page; may be async.

Promise<void>

MobileLockerError when pageSize is out of range.

MobileLockerCRMError on network/server error.

await mobilelocker.crm.eachAccountsPage(500, (chunk) => {
for (const account of chunk) {
// handle one account — never accumulate the full table
}
})
getAccount(accountID): Promise<CRMAccount>;

Get a specific CRM account by ID.

Parameter Type Description
accountID string The CRM account ID to fetch.

Promise<CRMAccount>

CRM account record.

MobileLockerCRMError on network failure, auth expiry, or server error.

getAddressesPage(limit, cursor?): Promise<Page<CRMAddress>>;

Get one page of CRM addresses. Same cursor envelope as crm.getAccountsPage (iOS 5.5.0+, limit 1…5000). Prefer crm.eachAddressesPage or crm.query.

Parameter Type
limit number
cursor? string

Promise<Page<CRMAddress>>

eachAddressesPage(pageSize, handler): Promise<void>;

Walk CRM addresses page by page (meta.cursor.next only). Replaces removed getAddresses().

Parameter Type
pageSize number
handler (chunk) => void | Promise<void>

Promise<void>

getAddress(addressID): Promise<CRMAddress>;

Get a specific CRM address by ID.

Parameter Type Description
addressID string The CRM address ID to fetch.

Promise<CRMAddress>

CRM address record.

MobileLockerCRMError on network failure, auth expiry, or server error.

getContactsPage(limit, cursor?): Promise<Page<CRMContact>>;

Get one page of CRM contacts. Same cursor envelope as crm.getAccountsPage (iOS 5.5.0+, limit 1…5000). Prefer crm.eachContactsPage or crm.query.

Parameter Type
limit number
cursor? string

Promise<Page<CRMContact>>

eachContactsPage(pageSize, handler): Promise<void>;

Walk CRM contacts page by page (meta.cursor.next only). Replaces removed getContacts().

Parameter Type
pageSize number
handler (chunk) => void | Promise<void>

Promise<void>

await mobilelocker.crm.eachContactsPage(500, (chunk) => {
for (const contact of chunk) {
// handle one contact
}
})
getContact(contactID): Promise<CRMContact>;

Get a specific CRM contact by ID.

Parameter Type Description
contactID string The CRM contact ID to fetch.

Promise<CRMContact>

CRM contact record.

MobileLockerCRMError on network failure, auth expiry, or server error.

getLeadsPage(limit, cursor?): Promise<Page<CRMLead>>;

Get one page of CRM leads. Same cursor envelope as crm.getAccountsPage (iOS 5.5.0+, limit 1…5000). Prefer crm.eachLeadsPage or crm.query.

Parameter Type
limit number
cursor? string

Promise<Page<CRMLead>>

eachLeadsPage(pageSize, handler): Promise<void>;

Walk CRM leads page by page (meta.cursor.next only). Replaces removed getLeads().

Parameter Type
pageSize number
handler (chunk) => void | Promise<void>

Promise<void>

getLead(leadID): Promise<CRMLead>;

Get a specific CRM lead by ID.

Parameter Type Description
leadID string The CRM lead ID to fetch.

Promise<CRMLead>

CRM lead record.

MobileLockerCRMError on network failure, auth expiry, or server error.

getUsersPage(limit, cursor?): Promise<Page<CRMUser>>;

Get one page of CRM users. Same cursor envelope as crm.getAccountsPage (iOS 5.5.0+, limit 1…5000). Prefer crm.eachUsersPage or crm.query.

Parameter Type
limit number
cursor? string

Promise<Page<CRMUser>>

eachUsersPage(pageSize, handler): Promise<void>;

Walk CRM users page by page (meta.cursor.next only). Replaces removed getUsers().

Parameter Type
pageSize number
handler (chunk) => void | Promise<void>

Promise<void>

getUser(userID): Promise<CRMUser>;

Get a specific CRM user by ID.

Parameter Type Description
userID string The CRM user ID to fetch.

Promise<CRMUser>

CRM user record.

MobileLockerCRMError on network failure, auth expiry, or server error.

openCustomerPicker(): Promise<PickerResult>;

Open the native customer picker UI and let the user select one or more customers.

Promise<PickerResult>

An object with status ('selected' or 'cancelled') and an optional customers array.

iOS app only. Throws in all other environments.

MobileLockerError if called outside the iOS app.

MobileLockerCRMError on network failure or server error.

const { status, customers } = await mobilelocker.crm.openCustomerPicker()
if (status === 'selected') console.log(customers)
getCurrentCustomers(): Promise<Customer[]>;

Get the customers currently associated with the active presentation session.

Promise<Customer[]>

Array of Customer objects.

MobileLockerCRMError on network failure or server error.

getRecentCustomers(): Promise<Customer[]>;

Get the customers most recently viewed by the current user.

Promise<Customer[]>

Array of Customer objects, newest first.

MobileLockerCRMError on network failure or server error.

isCurrentCustomer(objectID): Promise<boolean>;

Check whether a CRM object is currently associated with the active session.

Parameter Type Description
objectID string The CRM object ID to check (e.g. a Salesforce Account ID).

Promise<boolean>

true if the customer is current, false otherwise.

MobileLockerCRMError on network failure or server error.

setCurrentCustomers(customerIDs): Promise<void>;

Replace the current customers for the active session.

Parameter Type Description
customerIDs string[] Array of CRM object IDs to set as current.

Promise<void>

MobileLockerCRMError on network failure or server error.

addCurrentCustomer(customerID): Promise<void>;

Add a single customer to the current session without replacing existing ones.

Parameter Type Description
customerID string The CRM object ID of the customer to add.

Promise<void>

MobileLockerCRMError on network failure or server error.

removeCurrentCustomer(customerID): Promise<void>;

Remove a single customer from the current session.

Parameter Type Description
customerID string The CRM object ID of the customer to remove.

Promise<void>

MobileLockerCRMError on network failure or server error.

clearCurrentCustomers(): Promise<void>;

Remove all customers from the current session.

Promise<void>

MobileLockerCRMError on network failure or server error.

refresh(options?): Promise<CRMRefreshResult>;

Trigger a CRM data refresh for the current user.

Parameter Type Description
options? { mode?: CRMRefreshMode; } -
options.mode? CRMRefreshMode 'incremental' (default) syncs only new/changed records; 'full' re-syncs everything.

Promise<CRMRefreshResult>

An object with status: 'started' if the refresh was queued, 'not_connected' if the CRM is unreachable.

MobileLockerCRMError on auth expiry or server error.

const { status } = await mobilelocker.crm.refresh({ mode: 'full' })
query(soql, parameters?): Promise<CRMQueryResult>;

Execute a SOQL query against the connected CRM.

Prefer this over full offline walks when you need filtered CRM data.

Parameter Type Description
soql string A valid SOQL SELECT statement.
parameters? Record<string, unknown> Optional named bind parameters referenced in the SOQL string.

Promise<CRMQueryResult>

A CRMQueryResult containing rows, totalSize, and done.

MobileLockerCRMError with code SOQLInvalid on a syntax error, or on network/auth failure.

const result = await mobilelocker.crm.query('SELECT Id, Name FROM Account WHERE Name = :name', { name: 'Acme' })