none
[E2010] [EWS Java API 1.1][JAVA] - ReminderDueBy Property of tasks cannot be ussed for filtering tasks. RRS feed

  • Question

  • Hi,

    I am trying to filter all the tasks based on ReminderDueBy field. Please see the test code below.

        Task task = new Task( service );
        task.setStatus( TaskStatus.NotStarted );
        task.setPercentComplete( "0.0" );
        task.setActualWork( 0 );
        task.setTotalWork( 0 );
        Date reminderDate = new Date();
        task.setReminderDueBy( reminderDate );
        Collection < Item > items = new ArrayList < Item >();
        items.add( task );
        ServiceResponseCollection < ServiceResponse > responses = service.createItems( items, new FolderId(
            WellKnownFolderName.Tasks ), MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone );
    
        System.out.println( responses.getOverallResult() );
    
        Field item = responses.getResponseAtIndex( 0 ).getClass().getDeclaredField( "item" );
        item.setAccessible( true );
        Task createdTask = ( Task ) item.get( responses.getResponseAtIndex( 0 ) );
        System.out.println( createdTask.getReminderDueBy() );
    
        SearchFilterCollection searchFilter = new SearchFilterCollection();
        SearchFilter.IsGreaterThanOrEqualTo reminderDateFilter = new SearchFilter.IsGreaterThanOrEqualTo();
        reminderDateFilter.setPropertyDefinition( TaskSchema.ReminderDueBy );
        reminderDateFilter.setValue( new Date( reminderDate.getTime() - 1000 ) );
        searchFilter.add( reminderDateFilter );
        FindItemsResults < Item > results = service.findItems( new FolderId( WellKnownFolderName.Tasks ), searchFilter,
            new ItemView( 100 ) );
        System.out.println( results.getTotalCount() );

    This throws ServiceResponseException, when I try to findItems using the filter.

    Exception in thread "main" microsoft.exchange.webservices.data.ServiceResponseException: The property can not be used with this type of restriction.
    	at microsoft.exchange.webservices.data.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:264)
    	at microsoft.exchange.webservices.data.ServiceResponse.throwIfNecessary(ServiceResponse.java:252)
    	at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:150)
    	at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:949)
    	at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:1002)
    	at test.Bug86604.main(Bug86604.java:60)
    

    It seems the ReminderDueBy field cannot be used for filtering tasks. How can I solve this problem?

    Regards,
    Paul

     

     

    Wednesday, March 9, 2011 7:24 AM

Answers

  • Hi,

    I solved this problem by using the extendedpropertydefinition for the reminder date. Check the below code.

        Task task = new Task( service );
        task.setStatus( TaskStatus.NotStarted );
        task.setPercentComplete( "0.0" );
        task.setActualWork( 0 );
        task.setTotalWork( 0 );
        Date reminderDate = new Date();
        task.setReminderDueBy( reminderDate );
        task.setIsReminderSet( true );
        Collection < Item > items = new ArrayList < Item >();
        items.add( task );
        service.createItems( items, new FolderId(
            WellKnownFolderName.Tasks ), MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone );
    
        PropertyDefinitionBase reminderDateProperty = new ExtendedPropertyDefinition( UUID
            .fromString( "00062008-0000-0000-C000-000000000046" ), 0x8502, MapiPropertyType.SystemTime );
    
        SearchFilter.IsGreaterThanOrEqualTo searchFilter = new SearchFilter.IsGreaterThanOrEqualTo();
        searchFilter.setPropertyDefinition( reminderDateProperty );
        searchFilter.setValue( new Date( reminderDate.getTime() - 1000 ) );
        FindItemsResults < Item > results = service.findItems( WellKnownFolderName.Tasks, searchFilter, new ItemView(
            1000 ) );
        System.out.println( results.getTotalCount() );
        Task tsk = ( Task ) results.getItems().get( 0 );
        System.out.println( tsk.getReminderDueBy() );

    Regards,

    Paul

     

    • Marked as answer by PaulNibin Thursday, March 10, 2011 9:44 AM
    Thursday, March 10, 2011 9:43 AM