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

Addressbook.multivalue.replaceValueAtIndex

Replaces the value at the given index.

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

Deprecated

This function was deprecated. Use Contacts functions instead.

MBS( "Addressbook.multivalue.replaceValueAtIndex"; index; value )   More

Parameters

Parameter Description Example
index The index of the value that will be replaced. $index
value The new value. $value

Result

Returns OK on success and error on failure.

Description

Replaces the value at the given index.

Examples

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

See also

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 9th December 2019


Addressbook.multivalue.replaceLabelAtIndex - Addressbook.multivalue.setPrimaryIdentifier