Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Replaces the value at the given index.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Addressbook | 3.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |
This function was deprecated. Use Contacts functions instead.
Parameter | Description | Example |
---|---|---|
index | The index of the value that will be replaced. | $index |
value | The new value. | $value |
Returns OK on success and error on failure.
Replace an email:
# find my ID
Set Variable [$personID; Value:MBS( "Addressbook.me" )]
# get email list
Set Variable [$r; Value:MBS( "Addressbook.record.valueForProperty"; $personID; "EmailProperty" )]
# show first email in list
Set Variable [$firstValue; Value:MBS( "Addressbook.multivalue.valueAtIndex"; 0 )]
Show Custom Dialog ["First Email"; $firstValue]
# replace first email with new email
Set Variable [$r; Value:MBS( "Addressbook.multivalue.replaceValueAtIndex"; 0; "test@test.test" )]
# show changed email
Set Variable [$firstValue; Value:MBS( "Addressbook.multivalue.valueAtIndex"; 0 )]
Show Custom Dialog ["First Email"; $firstValue]
# set back the email list
Set Variable [$r; Value:MBS( "Addressbook.record.SetValueForProperty"; $personID; "EmailProperty"; "" )]
# save it
Set Variable [$r; Value:MBS( "Addressbook.save" )]
Show Custom Dialog ["Saved"; $r]
Replace an address:
# Find someone...
Set Variable [ $personID ; Value: MBS( "Addressbook.searchPeopleWithName"; "Jon"; "Test" ) ]
If [ Length($personID) > 0 ]
# set Address
Set Variable [ $r ; Value: MBS( "Addressbook.record.valueForProperty"; $personID; "AddressProperty" ) ]
Set Variable [ $r ; Value: MBS( "Addressbook.multivalue.replaceValueAtIndex"; 0; "Street=5th avenue¶Zip=12345¶Country=USA¶City=New York" ) ]
Set Variable [ $r ; Value: MBS( "Addressbook.record.SetValueForProperty"; $personID; "AddressProperty"; "multivalue" ) ]
Set Variable [ $r ; Value: MBS( "Addressbook.save" ) ]
# get Address and show
Set Variable [ $r ; Value: MBS( "Addressbook.record.valueForProperty"; $personID; "AddressProperty" ) ]
Set Variable [ $Address ; Value: MBS( "Addressbook.multivalue.valueAtIndex"; 0) ]
Show Custom Dialog [ "Address" ; $Address ]
End If
Created 18th August 2014, last changed 9th December 2019
Addressbook.multivalue.replaceLabelAtIndex - Addressbook.multivalue.setPrimaryIdentifier
Feedback: Report problem or ask question.