locked
EWS - FindItem RRS feed

  • Question

  • HI,

     

    Whether can I retreive a calenderItem in FindItem using ExtendedProperty's Name and Value (Custom Property Name and also its Value) which falls in a given date range

     

    For Example while inserting a CalenderItem I added a Custom Property (Name - TYPE, Value - Meeting).

     

    I need to retireve the calenderItem having the extended property with name as TYPE and its value as Meeting which falls in a given date range.

     

    Thanks in advance

    Palani Kumar D

     

    Tuesday, October 7, 2008 3:50 AM

All replies

  • You can't use a CalendarView and a Restriction at the same time so you need to look at working around this usually the best thing to do is grab all the appointments for the daterange using a calendarView in a FindItem request and include your custom property. Then enumerate through the appointments and check the value of that property on each one.

     

    cheers

    Glen

     

     

    Wednesday, October 8, 2008 2:12 AM
  • Yes you can use EWS restrictions to do this.

    This is the XML you can use –

     

    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">

        <soap:Header>

            <t:RequestServerVersion Version="Exchange2007_SP1" />

        </soap:Header>

        <soap:Body>

            <FindItem Traversal="Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">

                <ItemShape>

                    <t:BaseShape>IdOnly</t:BaseShape>

                </ItemShape>

                <Restriction>

                    <t:And>

                        <t:IsEqualTo>

                            <t:ExtendedFieldURI PropertySetId="be4e8122-c232-4f52-8f13-56348e84f05f" PropertyName="type" PropertyType="String" />

                            <t:FieldURIOrConstant>

                                <t:Constant Value="meeting" />

                            </t:FieldURIOrConstant>

                        </t:IsEqualTo>

                        <t:IsGreaterThanOrEqualTo>

                            <t:FieldURI FieldURI="calendarTongue Tiedtart"/>

                            <t:FieldURIOrConstant>

                                <t:Constant Value="2009-03-13T09:00:00Z" />

                            </t:FieldURIOrConstant>

                        </t:IsGreaterThanOrEqualTo>

                        <t:IsLessThanOrEqualTo>

                            <t:FieldURI FieldURI="calendar:End"/>

                            <t:FieldURIOrConstant>

                                <t:Constant Value="2010-03-13T10:00:00Z" />

                            </t:FieldURIOrConstant>

                        </t:IsLessThanOrEqualTo>

                    </t:And>

                </Restriction>

                <ParentFolderIds>

                    <tBig SmileistinguishedFolderId Id="calendar"/>

                </ParentFolderIds>

            </FindItem>

        </soap:Body>

    </soap:Envelope>

     

    The above request will return those calendar items that have the extended property names “type” set to “meeting” and which have a start date greater than or equal to 2009-03-13T09:00:00Z and an end date less than or equal to 2010-03-13T10:00:00Z.

     

    Wednesday, October 8, 2008 4:51 PM
  • That will work but wont work for all calendar items if you don't use calendar paging then the finditem request wont expand recurring appointments so you will be missing any instances of these type of appointments/meeting during the time period you want to query. It really depends if your looking for a solution that will deal with all calendar item types.

     

    Cheers

    Glen

     

     

    Wednesday, October 8, 2008 9:22 PM
  • Anyone figured out how to get instances of recurring appointments using finditem instead of findappointment?

    Currently I am doing 

     

       var itemView = new ItemView(pageSize, pageOffset);
       itemView.PropertySet = BasePropertySet.IdOnly;
       itemView.OrderBy.Add(AppointmentSchema.Start, SortDirection.Ascending);
    
       var dateRangeSearchFilter = new SearchFilter.SearchFilterCollection(
        LogicalOperator.And,
        new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, start),
        new SearchFilter.IsLessThan(AppointmentSchema.End, end));
    
       var results = service.FindItems(WellKnownFolderName.Calendar, dateRangeSearchFilter, itemView);

     

    But this only returns master events missing all recurring occurrences.

    I used to do 

     

       var calendarView = new CalendarView(start, end, pageSize);
       calendarView.PropertySet = BasePropertySet.IdOnly;
       var results = service.FindAppointments(WellKnownFolderName.Calendar, calendarView);

     

    This seems returning all recurring occurrences but I don't know how to apply page offset for this one.

     

    Brian.

     

    • Proposed as answer by Humblesticker Tuesday, September 7, 2010 8:15 PM
    Tuesday, September 7, 2010 6:39 PM
  • I found more information about this from other threads. Basically CalendarView is only way to expand recurrences.

    How do I page appointments using CalendarView? ItemView has offset property I can use while CalendarView doesn't.

     

    Brian.

    Tuesday, September 7, 2010 8:17 PM