none
FindItems by GlobalAppointmentId - PidLidGlobalObjectId RRS feed

  • Question

  • Hi, I have Microsoft.Exchange.WebServices.Data.Appointment.GlobalAppointmentId (string) and I want to use new Managed EWS API to find item (appointment) according to this Global ID. The problem is, I cannot reach PidLidGlobalObjectId property. Here are two definitions of Extended proeperty i tried:

    ExtendedPropertyDefinition PROP_DEF_PidLidGlobalObjectId = new ExtendedPropertyDefinition(
    	DefaultExtendedPropertySet.Meeting,
    	 0x00030102,
    	 MapiPropertyType.Binary);
    
    ExtendedPropertyDefinition PROP_DEF_PidLidGlobalObjectId = new ExtendedPropertyDefinition(0x00000003, MapiPropertyType.Binary);

    I think that the problem is with the definition of Extended property. Here is the snippet how I am trying to find the item:

    SearchFilter filter = new SearchFilter.IsEqualTo(PROP_DEF_PidLidGlobalObjectId, globalIdValue);
    Folder fld = Folder.Bind(this.Service, folderId);
    FindItemsResults<Item> results = fld.FindItems(filter, this.View);
    

    The problem is, that it doesn't find specified appointment. When I tried to get GlobalAppointmentId value using Appointment.TryGetProperty(PROP_DEF_PidLidGlobalObjectId,out value) it returned null. But I know, that appointment has this property. When I tried it with my custom extended property it was ok.

     




    Tuesday, April 26, 2011 3:07 PM

All replies

  • So here is the right property definition for GlobalAppointmentID:

    ExtendedPropertyDefinition PROP_DEF_PidLidGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting,0x00000003, MapiPropertyType.Binary);

    There are two important things:

    1. Don't forget to load this property, before you call appointment.TryGetProperty (using EWS managed API): app.Load(new PropertySet(PROP_DEF_PidLidGlobalObjectId));

    2. This property is binary, so the value is returnet as byte array. Call Convert.ToBase64String to get string value.

    Because of the 2nd note, I am not able to Search items according to this property. How to find items according to GlobalAppointmentID?

    When you use SearchFilter filter = new SearchFilter.IsEqualTo(PROP_DEF_PidLidGlobalObjectId, byteArrayValue) in FolderId.Search(filter, itemView) you get ArgumentException with message:"{"Validation failed. Parameter name: searchFilter"}" and InnerException: "Values of type 'Byte[]' cannot be as comparison values in search filters."

     

    Tuesday, April 26, 2011 5:42 PM
  • You just need to convert the bytearray to a Base64String and use that in the searchfilter eg

    ExtendedPropertyDefinition pidCleanGlobalObjId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 35, MapiPropertyType.Binary);
    SearchFilter sf = new SearchFilter.IsEqualTo(pidCleanGlobalObjId,Convert.ToBase64String(searchval));
    
    

    Cheers
    Glen

    Wednesday, April 27, 2011 10:25 AM
  • Thanks Glen, at least i know, that I can pass to SearchFilter string value even if the property is Binary. The strange thing is, that it is showing me different values. The value of PidLidCleanGlobalObjectId property returned by Appointment.PropertyAccessor.GetProperty and the value of PidLidCleanGlobalObjectId property returned by EWS using TryGetProperty are different.

     

    I also tried to add my custom property, set the value and saved. Then I returned value of this custom property by EWS and it was different. When I was trying in debugg mode to change ItemViews, Load different property set, then I was able sometimes to produce the same values. But when I ran the code again, it was different again. This behaviour is very frustrating I really don't know what is causing that.

    EDIT:

    Here is value returned by PropertyAccessor.GetProperty: 

     "040000008200E00074C5B7101A82E0080000000000E986DFC904CC01000000000000000010000000DB48CC627C4BBF4BA14A80F6036B5C5A"

    Here is value returned by Appointment.TryGetProperty(EWS):

    "BAAAAIIA4AB0xbcQGoLgCAAAAAAA6YbfyQTMAQAAAAAAAAAAEAAAANtIzGJ8S79LoUqA9gNrXFo="

    EDIT TWO:

    So it was my fault. I didn't use Convert.ToBase64String method but PropertyAccesor.BinaryToString and it produced different value. I will have to look at these two methods closely.

    Wednesday, April 27, 2011 12:26 PM
  • The other thing is the value you use/see within the OOM is the hex representation of the binary value so if you want to do comparisons you should use just

    BitConverter.ToString(byteval).Replace("-","")

    Cheers
    Glen

    Thursday, April 28, 2011 9:50 AM