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
Type Declaration
Section titled “Type Declaration”getAccountsPage()
Section titled “getAccountsPage()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
limit |
number |
Page size (1…5000). |
cursor? |
string |
From previous meta.cursor.next. Omit for the first page. |
Returns
Section titled “Returns”Promise<Page<CRMAccount>>
Page of CRMAccount records.
Throws
Section titled “Throws”MobileLockerError with code InvalidArgument when limit is out of range.
Throws
Section titled “Throws”MobileLockerCRMError on network failure, auth expiry, or server error.
eachAccountsPage()
Section titled “eachAccountsPage()”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+.
Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”MobileLockerError when pageSize is out of range.
Throws
Section titled “Throws”MobileLockerCRMError on network/server error.
Example
Section titled “Example”await mobilelocker.crm.eachAccountsPage(500, (chunk) => { for (const account of chunk) { // handle one account — never accumulate the full table }})getAccount()
Section titled “getAccount()”getAccount(accountID): Promise<CRMAccount>;Get a specific CRM account by ID.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
accountID |
string |
The CRM account ID to fetch. |
Returns
Section titled “Returns”Promise<CRMAccount>
CRM account record.
Throws
Section titled “Throws”MobileLockerCRMError on network failure, auth expiry, or server error.
getAddressesPage()
Section titled “getAddressesPage()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
limit |
number |
cursor? |
string |
Returns
Section titled “Returns”Promise<Page<CRMAddress>>
eachAddressesPage()
Section titled “eachAddressesPage()”eachAddressesPage(pageSize, handler): Promise<void>;Walk CRM addresses page by page (meta.cursor.next only). Replaces removed getAddresses().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pageSize |
number |
handler |
(chunk) => void | Promise<void> |
Returns
Section titled “Returns”Promise<void>
getAddress()
Section titled “getAddress()”getAddress(addressID): Promise<CRMAddress>;Get a specific CRM address by ID.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
addressID |
string |
The CRM address ID to fetch. |
Returns
Section titled “Returns”Promise<CRMAddress>
CRM address record.
Throws
Section titled “Throws”MobileLockerCRMError on network failure, auth expiry, or server error.
getContactsPage()
Section titled “getContactsPage()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
limit |
number |
cursor? |
string |
Returns
Section titled “Returns”Promise<Page<CRMContact>>
eachContactsPage()
Section titled “eachContactsPage()”eachContactsPage(pageSize, handler): Promise<void>;Walk CRM contacts page by page (meta.cursor.next only). Replaces removed getContacts().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pageSize |
number |
handler |
(chunk) => void | Promise<void> |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”await mobilelocker.crm.eachContactsPage(500, (chunk) => { for (const contact of chunk) { // handle one contact }})getContact()
Section titled “getContact()”getContact(contactID): Promise<CRMContact>;Get a specific CRM contact by ID.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
contactID |
string |
The CRM contact ID to fetch. |
Returns
Section titled “Returns”Promise<CRMContact>
CRM contact record.
Throws
Section titled “Throws”MobileLockerCRMError on network failure, auth expiry, or server error.
getLeadsPage()
Section titled “getLeadsPage()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
limit |
number |
cursor? |
string |
Returns
Section titled “Returns”eachLeadsPage()
Section titled “eachLeadsPage()”eachLeadsPage(pageSize, handler): Promise<void>;Walk CRM leads page by page (meta.cursor.next only). Replaces removed getLeads().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pageSize |
number |
handler |
(chunk) => void | Promise<void> |
Returns
Section titled “Returns”Promise<void>
getLead()
Section titled “getLead()”getLead(leadID): Promise<CRMLead>;Get a specific CRM lead by ID.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
leadID |
string |
The CRM lead ID to fetch. |
Returns
Section titled “Returns”Promise<CRMLead>
CRM lead record.
Throws
Section titled “Throws”MobileLockerCRMError on network failure, auth expiry, or server error.
getUsersPage()
Section titled “getUsersPage()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
limit |
number |
cursor? |
string |
Returns
Section titled “Returns”eachUsersPage()
Section titled “eachUsersPage()”eachUsersPage(pageSize, handler): Promise<void>;Walk CRM users page by page (meta.cursor.next only). Replaces removed getUsers().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pageSize |
number |
handler |
(chunk) => void | Promise<void> |
Returns
Section titled “Returns”Promise<void>
getUser()
Section titled “getUser()”getUser(userID): Promise<CRMUser>;Get a specific CRM user by ID.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
userID |
string |
The CRM user ID to fetch. |
Returns
Section titled “Returns”Promise<CRMUser>
CRM user record.
Throws
Section titled “Throws”MobileLockerCRMError on network failure, auth expiry, or server error.
openCustomerPicker()
Section titled “openCustomerPicker()”openCustomerPicker(): Promise<PickerResult>;Open the native customer picker UI and let the user select one or more customers.
Returns
Section titled “Returns”Promise<PickerResult>
An object with status ('selected' or 'cancelled') and an optional customers array.
Remarks
Section titled “Remarks”iOS app only. Throws in all other environments.
Throws
Section titled “Throws”MobileLockerError if called outside the iOS app.
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
Example
Section titled “Example”const { status, customers } = await mobilelocker.crm.openCustomerPicker()if (status === 'selected') console.log(customers)getCurrentCustomers()
Section titled “getCurrentCustomers()”getCurrentCustomers(): Promise<Customer[]>;Get the customers currently associated with the active presentation session.
Returns
Section titled “Returns”Promise<Customer[]>
Array of Customer objects.
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
getRecentCustomers()
Section titled “getRecentCustomers()”getRecentCustomers(): Promise<Customer[]>;Get the customers most recently viewed by the current user.
Returns
Section titled “Returns”Promise<Customer[]>
Array of Customer objects, newest first.
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
isCurrentCustomer()
Section titled “isCurrentCustomer()”isCurrentCustomer(objectID): Promise<boolean>;Check whether a CRM object is currently associated with the active session.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
objectID |
string |
The CRM object ID to check (e.g. a Salesforce Account ID). |
Returns
Section titled “Returns”Promise<boolean>
true if the customer is current, false otherwise.
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
setCurrentCustomers()
Section titled “setCurrentCustomers()”setCurrentCustomers(customerIDs): Promise<void>;Replace the current customers for the active session.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
customerIDs |
string[] |
Array of CRM object IDs to set as current. |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
addCurrentCustomer()
Section titled “addCurrentCustomer()”addCurrentCustomer(customerID): Promise<void>;Add a single customer to the current session without replacing existing ones.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
customerID |
string |
The CRM object ID of the customer to add. |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
removeCurrentCustomer()
Section titled “removeCurrentCustomer()”removeCurrentCustomer(customerID): Promise<void>;Remove a single customer from the current session.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
customerID |
string |
The CRM object ID of the customer to remove. |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
clearCurrentCustomers()
Section titled “clearCurrentCustomers()”clearCurrentCustomers(): Promise<void>;Remove all customers from the current session.
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”MobileLockerCRMError on network failure or server error.
refresh()
Section titled “refresh()”refresh(options?): Promise<CRMRefreshResult>;Trigger a CRM data refresh for the current user.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? |
{ mode?: CRMRefreshMode; } |
- |
options.mode? |
CRMRefreshMode |
'incremental' (default) syncs only new/changed records; 'full' re-syncs everything. |
Returns
Section titled “Returns”Promise<CRMRefreshResult>
An object with status: 'started' if the refresh was queued, 'not_connected' if the CRM is unreachable.
Throws
Section titled “Throws”MobileLockerCRMError on auth expiry or server error.
Example
Section titled “Example”const { status } = await mobilelocker.crm.refresh({ mode: 'full' })query()
Section titled “query()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
soql |
string |
A valid SOQL SELECT statement. |
parameters? |
Record<string, unknown> |
Optional named bind parameters referenced in the SOQL string. |
Returns
Section titled “Returns”Promise<CRMQueryResult>
A CRMQueryResult containing rows, totalSize, and done.
Throws
Section titled “Throws”MobileLockerCRMError with code SOQLInvalid on a syntax error, or on network/auth failure.
Example
Section titled “Example”const result = await mobilelocker.crm.query('SELECT Id, Name FROM Account WHERE Name = :name', { name: 'Acme' })