jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 302 forks source link

How to update contact fields like fileAs #574

Closed vielhuber closed 4 years ago

vielhuber commented 4 years ago

Version (e.g. 1.0, dev-master): 1.0 PHP version: 7.3 Microsoft Exchange version: 2013

How can I update simple fields like fileAs or name? In the examples folder there are email addresses and phones changed, but no basic information.

I've tried:

$field = new SetItemFieldType();
$field->IndexedFieldURI = new PathToUnindexedFieldType();
$field->IndexedFieldURI->FieldURI = UnindexedFieldURIType::CONTACTS_FILE_AS;
$field->Contact = new ContactItemType();
$field->Contact->fileAs = 'new value';
$change->Updates->SetItemField[] = $field;

Response (translated):

SoapFault: Request schema verification error: The 'FieldURI' attribute is invalid - The value 'contacts:FileAs' is invalid according to its data type 'http://schemas.microsoft.com/exchange/services/2006/types:DictionaryURIType' - Enumeration restriction failed... in Client.php on line 1631
vielhuber commented 4 years ago

Fixed (this was missing):

            $field = new SetItemFieldType();
            $field->FieldURI = new PathToUnindexedFieldType();
            $field->FieldURI->FieldURI = UnindexedFieldURIType::CONTACTS_FILE_AS_MAPPING;
            $field->Contact = new ContactItemType();
            $field->Contact->FileAsMapping = FileAsMappingType::NONE;
            $change->Updates->SetItemField[] = $field;