Respondido Accessing Calendar List Item in C# using CAML

  • segunda-feira, 30 de abril de 2012 11:26
     
     

    Hello,

    I have a calendar list in my sharepoint publishing site and I am accesing the list items in my server side code.

    And all is working fine regarding the fetching.

    But the problem is, I want the latest event to be fetched in the code and am using CAML query to achieve this.

    But what it's doing is giving me the latest event using the date filter(ie an event scheduled tomorrow).

    But what I want is if there is an event which is scheduled Today at some later time from now ,then it should return that event instead of the event occurring tomorrow.

    Below is my caml query for the same

    query.Query = @"<Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + today + "</Value></Geq></Where><OrderBy><FieldRef Name='EventDate' Ascending='TRUE' /></OrderBy>";

    I have included IncludeTimeValue='TRUE' but no luck.

    The event is a recurring event.

    Thanks in advance.

    Any help will be appreciated..

    Regards

    Soham

Todas as Respostas

  • segunda-feira, 30 de abril de 2012 18:09
     
     Resposta Proposta

    I had the same issue.

    This should fix it:

    "<Where><And><Geq><FieldRef Name='EventDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'><Today /></Value></Geq><IsNotNull><FieldRef Name='Title' /></IsNotNull></And></Where><OrderBy><FieldRef Name='EventDate' Ascending='True' /></OrderBy>";

    let me know if you still have issues.

    • Sugerido como Resposta GoingForward segunda-feira, 30 de abril de 2012 18:09
    •  
  • terça-feira, 1 de maio de 2012 06:42
     
     

    Thanks for your response but it still doesn't work

    It's not fetching my recurring events

    One more thing I have both recurring and non recurring events in my calendar list so 

    if a recurring event is latest I need to fetch that event and if a non recurring event is latest then i need to fetch that.

    For now with the above query I am getting only the latest non recurring event.

    Can you suggest anything else?

    Thank you


    Soham Patel


    • Editado Soham Patel terça-feira, 1 de maio de 2012 07:05
    •  
  • terça-feira, 1 de maio de 2012 13:22
     
     Respondido

    Hey Soham

    Glad you were able to square away one issue at least.

    Here is a link that can help you address the Recurrence aspect:

    http://sharepoint.stackexchange.com/questions/32178/populating-a-simple-custom-event-web-part-that-retrieves-information-from-the-oo

    • Sugerido como Resposta GoingForward quinta-feira, 3 de maio de 2012 13:10
    • Marcado como Resposta Soham Patel sexta-feira, 4 de maio de 2012 04:43
    •  
  • quinta-feira, 3 de maio de 2012 13:06
     
     

    Hello

    I have managed to solve the problem and your link was the help that I was looking for.

    Many many thanks... :-)

    Regards 

    Soham


    Soham Patel

  • quinta-feira, 3 de maio de 2012 13:12
     
     

    Your welcome!


    • Editado GoingForward quinta-feira, 3 de maio de 2012 13:48
    •