Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Addressbook.searchElementForProperty

Creates a new search element.

Component Version macOS Windows Linux Server iOS SDK
Addressbook 5.4 ✅ Yes ❌ No ❌ No ❌ No ❌ No

Deprecated

This function was deprecated. Use Contacts functions instead.

MBS( "Addressbook.searchElementForProperty"; Type; Property; Label; Key; Value; Comparison )   More

Parameters

Parameter Description Example
Type Whether to make search element for group or person. Can be "Group" or "Person". "Person"
Property The name of the property to search on, such as ABAddressProperty or ABLastNameProperty. "LastNameProperty"
Label The label name for a multivalue list, such as kABAddressHomeLabel, kABPhoneWorkLabel, or a user-specified label, such as Summer Home. If the specified property does not have multiple values, pass "". If the specified property does have multiple values, pass "" to search all the values.
Key The key name for a dictionary, such as kABAddressCityKey or kABAddressStreetKey. If the specified property is not a dictionary, pass "". If the specified property is a dictionary, pass "" to search all keys.
Value What you’re searching for. If empty, then the only supported value for comparison is ABEqual or ABNotEqual.
Comparison The comparison operator. Can be Equal, NotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, EqualCaseInsensitive, ContainsSubString, ContainsSubStringCaseInsensitive, PrefixMatch, PrefixMatchCaseInsensitive, BitsInBitFieldMatch, DoesNotContainSubString, DoesNotContainSubStringCaseInsensitive, NotEqualCaseInsensitive, SuffixMatch, SuffixMatchCaseInsensitive, WithinIntervalAroundToday, WithinIntervalAroundTodayYearless, NotWithinIntervalAroundToday, NotWithinIntervalAroundTodayYearless, WithinIntervalFromToday, WithinIntervalFromTodayYearless, NotWithinIntervalFromToday or NotWithinIntervalFromTodayYearless. "Equal"

Result

Returns ID or error.

Description

Creates a new search element.
Returns a search element object that specifies a query for records of this type.

Possible property names are UIDProperty, CreationDateProperty, ModificationDateProperty, FirstNameProperty, LastNameProperty, FirstNamePhoneticProperty, LastNamePhoneticProperty, NicknameProperty, MaidenNameProperty, BirthdayProperty, BirthdayComponentsProperty, OrganizationProperty, JobTitleProperty, HomePageProperty, URLsProperty, CalendarURIsProperty, EmailProperty, AddressProperty, OtherDatesProperty, OtherDateComponentsProperty, RelatedNamesProperty, DepartmentProperty, PhoneProperty, AIMInstantProperty, JabberInstantProperty, MSNInstantProperty, YahooInstantProperty, ICQInstantProperty, InstantMessageProperty, SocialProfileProperty, NoteProperty, MiddleNameProperty, MiddleNamePhoneticProperty, TitleProperty, SuffixProperty and GroupNameProperty.

Examples

Find a person with first name being Christian:

Set Variable [$e1; Value:MBS( "Addressbook.searchElementForProperty"; "person"; "FirstNameProperty"; ""; ""; "Christian"; "Equal" )]
Set Variable [$records; Value:MBS( "Addressbook.recordsMatchingSearchElement"; $e1)]
Set Variable [$record; Value:GetValue($records; 1)]
Set Variable [$name; Value:MBS( "Addressbook.record.displayname"; $record )]
Show Custom Dialog [$name]

Search people with related name being John:

Set Variable [$e1; Value:MBS( "Addressbook.searchElementForProperty"; "person"; "RelatedNamesProperty"; ""; ""; "John"; "ContainsSubStringCaseInsensitive" )]
Set Variable [$records; Value:MBS( "Addressbook.recordsMatchingSearchElement"; $e1)]
Set Variable [$record; Value:GetValue($records; 1)]
Set Variable [$name; Value:MBS( "Addressbook.record.displayname"; $record )]
Show Custom Dialog [$name]

Find all companies:

# Companies have PersonFlags = 1 while normal people have 0.
Set Variable [$e; Value:MBS( "Addressbook.searchElementForProperty"; "person"; "PersonFlags"; ""; ""; 1; "Equal" )]
Set Variable [$records; Value:MBS( "Addressbook.recordsMatchingSearchElement"; $e)]
Set Variable [$record; Value:GetValue($records; 1)]
Set Variable [$name; Value:MBS( "Addressbook.record.displayname"; $record )]
Show Custom Dialog [$name]

See also

Blog Entries

This function is free to use.

Created 26th October 2015, last changed 26th October 2015


Addressbook.searchElementForConjunction - Addressbook.searchGroupsWithName