Search...
startsWith( )
Refines a query to match items whose specified property value starts with a specified string.
Description
The startsWith()
function refines a ContactsQueryBuilder
to only
match items where the value of the specified property starts with a specified string.
Matching with startsWith()
is case-sensitive, so "TEXT"
does not start with "tex"
.
You can only use startsWith()
with a property whose value is a String.
Syntax
function startsWith(propertyName: string, value: string): ContactsQueryBuilder
startsWith Parameters
NAME
TYPE
DESCRIPTION
propertyName
string
The property whose value will be compared with value
.
Supported properties:
"primaryInfo.email"
"primaryInfo.phone"
"info.name.first"
"info.name.last"
"info.emails.email"
"info.phones.phone"
"info.addresses.street"
"info.addresses.city"
"info.company"
"info.jobTitle"
value
string
The value to match against.
Returns
A ContactsQueryBuilder
object that contains the refined query.
Return Type:
Was this helpful?
Add a
startsWith
filter to a queryCopy Code
1const query = contacts.queryContacts().startsWith("info.jobTitle", "VP");
Create a query, add a
startsWith
filter, and run itCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {56 return contacts.queryContacts()7 .startsWith("info.company", "Goog")8 .find()9 .then((results) => {10 if (results.items.length > 0) {11 const items = results.items;12 const firstItem = items[0];13 const pageSize = results.pageSize;14 const hasNext = results.hasNext();15 const hasPrev = results.hasPrev();16 const length = results.length;17 const query = results.query;1819 return items;20 } else {21 // Handle case where no matching items found22 }23 })24 .catch((error) => {25 console.error(error);26 })2728});