Skip to content

CRM

Interact with the team’s connected CRM from a presentation.

Public surface (crm):
getAccountsPage · eachAccountsPage · getAccount ·
getAddressesPage · eachAddressesPage · getAddress ·
getContactsPage · eachContactsPage · getContact ·
getLeadsPage · eachLeadsPage · getLead ·
getUsersPage · eachUsersPage · getUser ·
openCustomerPicker · getCurrentCustomers · getRecentCustomers ·
isCurrentCustomer · setCurrentCustomers · addCurrentCustomer ·
removeCurrentCustomer · clearCurrentCustomers · refresh · query

Entity IDs for CRM records are string (e.g. Salesforce IDs). Offline list APIs require Mobile Locker iOS 5.5.0+. Prefer filtered crm.query (SOQL) when you only need a subset. There is no getAccounts() / getContacts() full-list API (removed in SDK 2.0).

CRM failures throw MobileLockerCRMError (extends MobileLockerError). See Errors.

query(soql: string, parameters?: Record<string, unknown>): Promise<CRMQueryResult>
// CRMQueryResult: { rows: Record<string, unknown>[]; totalSize: number; done: boolean }
import mobilelocker from '@mobilelocker/javascript-sdk'
const results = await mobilelocker.crm.query(
'SELECT Id, Name FROM Account WHERE Name = :name',
{ name: 'Acme' },
)
// results.rows, results.totalSize, results.done

Host list contract (same for accounts, addresses, contacts, leads, users):

GET …?limit=1…5000&cursor=
→ { data, meta: { cursor: { next, count } } }
getAccountsPage(limit: number, cursor?: string): Promise<Page<CRMAccount>>
eachAccountsPage(
pageSize: number,
handler: (chunk: CRMAccount[]) => void | Promise<void>,
): Promise<void>
// Same pattern for Addresses, Contacts, Leads, Users

limit / pageSize must be an integer 1…5000 or the SDK throws InvalidArgument. Advance only with meta.cursor.next until it is null. Process one page at a time — do not reassemble large tables into one array.

await mobilelocker.crm.eachAccountsPage(500, (chunk) => {
for (const account of chunk) {
// handle one account
}
})
const page = await mobilelocker.crm.getAccountsPage(500)
if (page.meta.cursor.next) {
const next = await mobilelocker.crm.getAccountsPage(500, page.meta.cursor.next)
}
Entity One page Full walk By ID
Accounts getAccountsPage eachAccountsPage getAccount(id: string)
Addresses getAddressesPage eachAddressesPage getAddress(id: string)
Contacts getContactsPage eachContactsPage getContact(id: string)
Leads getLeadsPage eachLeadsPage getLead(id: string)
Users getUsersPage eachUsersPage getUser(id: string)
const account = await mobilelocker.crm.getAccount(accountID)
const address = await mobilelocker.crm.getAddress(addressID)
const contact = await mobilelocker.crm.getContact(contactID)
const lead = await mobilelocker.crm.getLead(leadID)
const user = await mobilelocker.crm.getUser(userID)
openCustomerPicker(): Promise<PickerResult>
// PickerResult = WithStatusBooleans<{ status: 'selected' | 'cancelled'; customers?: Customer[] }>
// booleans: isSelected, isCancelled

Throws UnsupportedEnvironment outside the iOS app.

const result = await mobilelocker.crm.openCustomerPicker()
// Prefer either style — both exist on the result:
if (result.status === 'selected') {
console.log(result.customers)
}
if (result.isSelected) {
console.log(result.customers)
}
getCurrentCustomers(): Promise<Customer[]>
getRecentCustomers(): Promise<Customer[]>
isCurrentCustomer(objectID: string): Promise<boolean>
setCurrentCustomers(customerIDs: string[]): Promise<void>
addCurrentCustomer(customerID: string): Promise<void>
removeCurrentCustomer(customerID: string): Promise<void>
clearCurrentCustomers(): Promise<void>
const current = await mobilelocker.crm.getCurrentCustomers()
const recent = await mobilelocker.crm.getRecentCustomers()
const isCurrent = await mobilelocker.crm.isCurrentCustomer(objectID)
await mobilelocker.crm.setCurrentCustomers([id1, id2])
await mobilelocker.crm.addCurrentCustomer(id)
await mobilelocker.crm.removeCurrentCustomer(id)
await mobilelocker.crm.clearCurrentCustomers()
refresh(options?: { mode?: 'incremental' | 'full' }): Promise<CRMRefreshResult>
// CRMRefreshResult = WithStatusBooleans<{ status: 'started' | 'not_connected' }>
// booleans: isStarted, isNotConnected
// Default mode: 'incremental'
const { status, isStarted, isNotConnected } = await mobilelocker.crm.refresh({
mode: 'incremental', // or 'full'
})
  • Contacts — user address book (different domain from CRM contacts)
  • ErrorsMobileLockerCRMError, CRMErrorCode
  • Scanner — capture leads on device