jamesiarmes / php-ews

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

How to update multiple Extended Property with one request #537

Open OliverB911 opened 5 years ago

OliverB911 commented 5 years ago

Hello,

I need your help. I have a script to modify street, zipcode, phonenumbers and so on with 1 request. I add the first "extended property" to modify the title. Works.

I copy & paste the block for the next extended property (customer no.). Now I get a scheme error: "The id attribute was not declared"

    //////////////////////////////////////////////////////////////
    // Build the extended property and set it on the item.
    $property = new ExtendedPropertyType();
    $property->ExtendedFieldURI = new PathToExtendedFieldType();
    $property->ExtendedFieldURI->PropertyTag = '0x3A45';
    $property->ExtendedFieldURI->PropertyType = MapiPropertyTypeType::STRING;
    $property->Value = 'Mr.';
    $contact->ExtendedProperty = $property;

    // Build the set item field object and set the item on it.
    $field = new SetItemFieldType();
    $field->ExtendedFieldURI = new PathToExtendedFieldType();
    $field->ExtendedFieldURI->PropertyTag = '0x3A45';
    $field->ExtendedFieldURI->PropertyType = MapiPropertyTypeType::STRING;
    $field->Contact = $contact;

    $change->Updates->SetItemField[] = $field;
    //////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////
    // Build the extended property and set it on the item.
    $property = new ExtendedPropertyType();
    $property->ExtendedFieldURI = new PathToExtendedFieldType();
    $property->ExtendedFieldURI->PropertyTag = '0x3A4A';
    $property->ExtendedFieldURI->PropertyType = MapiPropertyTypeType::STRING;
    $property->Value = 'CustomNo. 12345';
    $contact->ExtendedProperty = $property;

    // Build the set item field object and set the item on it.
    $field = new SetItemFieldType();
    $field->ExtendedFieldURI = new PathToExtendedFieldType();
    $field->ExtendedFieldURI->PropertyTag = '0x3A4A';
    $field->ExtendedFieldURI->PropertyType = MapiPropertyTypeType::STRING;
    $field->Contact = $contact;

    $change->Updates->SetItemField[] = $field;
    ////////////////////////////////////////////////////////////////

Thank you Olli