SharePoint Recurring Events Are Random? - sharepoint

Note: This question is similar to an existing, unanswered question (CAML OrderBy for SharePoint Recurring Calendar Event).
How can I use the Lists.asmx web service to retrieve recurring events that occur today or later?
I am providing the <CalendarDate>2019-06-25T15:55:04.108Z</CalendarDate> parameter when sending the request to the /_vti_bin/Lists.asmx web service, yet I'm still receiving events from the past (as shown in the screenshot below)!
This is the XML response (screenshot). Notice how the event dates are before today even though "CalendarDate" is specified as "2019-06-25":
This is the XML payload sent with the request:
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>{ my list GUID }</listName>
<query>
<Query>
<OrderBy>
<FieldRef Ascending='TRUE' Name='EventDate' />
</OrderBy>
<Where>
<And>
<Eq>
<FieldRef Name="fRecurrence" />
<Value Type="Boolean">1</Value>
</Eq>
<DateRangesOverlap>
<FieldRef Name="EventDate" />
<FieldRef Name="EndDate" />
<FieldRef Name="RecurrenceID" />
<Value Type='DateTime'>
<Year/>
</Value>
</DateRangesOverlap>
</And>
</Where>
</Query>
</query>
<viewFields>
<ViewFields>
<FieldRef Name="Category" />
<FieldRef Name="Location" />
</ViewFields>
</viewFields>
<queryOptions>
<QueryOptions>
<ViewAttributes Scope="RecursiveAll" />
<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>
<DateInUtc>TRUE</DateInUtc>
<ExpandRecurrence>TRUE</ExpandRecurrence>
<CalendarDate>2019-06-25T15:55:04.108Z</CalendarDate>
<RecurrenceOrderBy>TRUE</RecurrenceOrderBy>
</QueryOptions>
</queryOptions>
<rowLimit>20</rowLimit>
</GetListItems>
</soap:Body>
</soap:Envelope>
Edit: The following is an example of an event that is not being returned by the query above.

Year does not honour the CalendarDate property - it returns previous events that happened within a year from current date and future events a year from current date.
Use <Value Type='DateTime'><Now /></Value> in the DateRangesOverlap and remove the CalendarDate to retrieve recurring events that occur today or later

Related

SharePoint 2013 Columns Sorting Order

I am quite new in Sharepoint. I am working on sharepoint 2013. I have created a content type with Visual Studio.
I have written a query to sort the columns.
<OrderBy>
<FieldRef Name='Order' Ascending='True' />
<FieldRef Name='SortingOrder' Ascending='False' />
<FieldRef Name='IsFeatured1' Ascending='False' />
<FieldRef Name='Created' Ascending='False' />
</OrderBy>";
I just want to know which column will execute first. I am quite unable to understand the flow.
I want order something like that..
IsFreatured1
SortingOrder
Order
Created
The order in which the fields appear in the <OrderBy> node, is the order in which they are sorted.
So, to get the requirement you specified in your question, you have to use this OrderBy statement:
<OrderBy>
<FieldRef Name='IsFeatured1' Ascending='False' />
<FieldRef Name='SortingOrder' Ascending='False' />
<FieldRef Name='Order' Ascending='True' />
<FieldRef Name='Created' Ascending='False' />
</OrderBy>
https://msdn.microsoft.com/en-us/library/office/ms467378.aspx

Reporting Services, get data from any Sharepoint List

I am trying to build an SSRS (2008R2) report based on a Sharepoint (2010) List.
The main problem is that the List on which the report will run has to be a report parameter.I know what the list structure will be, but the sharepoint site can contain several list instances having this structure, and when running the report, the user has to choose the List Name.
Also, the report has two date parameters, MinDateTime and MaxDateTime, and selects only the records with times between these two.
From what I can tell, there are at least two approaches to building the report:
Use a Sharepoint List Data Source and write the Dataset query in CAML, specify the site in the DataSource, let SSRS handle the rest of the details. The problem in this case is that I can't specify the ListName as a report parameter. The DataSet query looks like this:
<pre>
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ListName>BusinessList1</ListName>
<ViewFields>
<FieldRef Name="Title" />
<FieldRef Name="BusinessUnit" />
<FieldRef Name="ScanDateTime" />
</ViewFields>
<Query>
<Where>
<And>
<Geq>
<FieldRef Name="ScanDateTime" />
<Value Type="DateTime">
<Parameter Name="MinScanDateTime" />
</Value>
</Geq>
<Leq>
<FieldRef Name="ScanDateTime" />
<Value Type="DateTime">
<Parameter Name="MaxScanDateTime" />
</Value>
</Leq>
</And>
</Where>
</Query>
</RSSharePointList>
Use an XML Data Source and write the Dataset query in soap-readable XML, access the /_vti_bin/lists.asmx webservice directly. The query should look something like this (including the list name as a parameter). However, I couldn't make it work at all with the Date parameters. Where should they be added?
<pre>
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<Parameters>
<Parameter Name="listName">
<DefaultValue>BusinessList1</DefaultValue>
</Parameter>
<Parameter Name="viewFields">
<ViewFields>
<FieldRef Name="Title" />
<FieldRef Name="BusinessUnit" />
<FieldRef Name="ScanDateTime" />
</ViewFields>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>
Any direction would be great.
Thanks,
You can use option 1, writing the query as an expression. Build up a long string with the parameter in the middle. You need a separate query to supply the list of BusinessLists to the parameter.
Expression would look like this:
="<pre>
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ListName>"
& Parameters!BusinessList.value &
"</ListName>
<ViewFields>
<FieldRef Name="Title" />
<FieldRef Name="BusinessUnit" />
<FieldRef Name="ScanDateTime" />
</ViewFields>
<Query>
<Where>
<And>
<Geq>
<FieldRef Name="ScanDateTime" />
<Value Type="DateTime">
<Parameter Name="MinScanDateTime" />
</Value>
</Geq>
<Leq>
<FieldRef Name="ScanDateTime" />
<Value Type="DateTime">
<Parameter Name="MaxScanDateTime" />
</Value>
</Leq>
</And>
</Where>
</Query>
</RSSharePointList>"
[EDIT]:
I'm not sure where the pre tag came from either. I've run through creating a test report using the sharepoint list connection type and it doesn't add that. Check out this MS link on the basics.
It points out that you don't need to specify the fields to return, so a very basic query expression looks like this (with my stuffed parameter added):
="<RSSharePointList xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><ListName>" & Parameters!List.Value & "</ListName></RSSharePointList>"
In my original example above I failed to mention that you need to escape the double quotes within the XML by doubling them up. I've tested this and it works well.

Pagefieldvalue in queryoverride CAML for Sharepoint Publishing page

I am having issues setting more than three filters using the queryoverride property. It works just fine if i pass fixed values to the fields like instead of [PageFieldValue:Primary Office], if i feed in 'XYZ Office' then it is able to read that value and pull content based on it...but not with the PageFieldValue...I am trying to pull content from other pages in the page libray that match the primary office value of the current page...so If I am in Doctor X's page and his primary office is XYZ then it should pull all other doctors from XYZ Office, where XYZ office could be the other doctor's primary office or other extra practice location?? Please any sharepoint GURU??
<Query>
<Where>
<And>
<Neq>
<FieldRef Name='Title' />
<Value Type='Text'>[PageFieldValue:Title]</Value>
</Neq>
<Or>
<Eq>
<FieldRef Name='Office' />
<Value Type='Text'>[PageFieldValue:Primary Office]</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name='Office1Name2' />
<Value Type='Text'>[PageFieldValue:Primary Office]</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name='OtherOffice2Name' />
<Value Type='Text'>[PageFieldValue:Primary Office]</Value>
</Eq>
<Eq>
<FieldRef Name='OtherOffice3Name' />
<Value Type='Text'>[PageFieldValue:Primary Office]</Value>
</Eq>
</Or>
</Or>
</Or>
</And>
</Where>
</Query>

How to query all lists that use a certain content type in SharePoint?

I have the following CAML query:
<Where>
<And>
<Eq>
<FieldRef Name='PublishToSM' />
<Value Type='Boolean'>True</Value>
</Eq>
<IsNull>
<FieldRef Name='SMUpdateDate' />
</IsNull>
</And>
</Where>
I have only one content type that uses these fields. When I run this query against a list that uses this content type everything works fine. When I run it against a List that does not it throws the error: One or more field types are not installed properly. Go to the list settings page to delete these fields.
I would like to be able to search all Lists on all websites in a site collection. Can this be done without erroring out?
Use SPSiteDataQuery, add a where clause to include the content type. i.e.:
<Where>
<And>
<Eq>
<FieldRef Name='ContentType' />
<Value Type='Text'>CONTENTTYPE NAME</Value>
</Eq>
<And>
<Eq>
<FieldRef Name='PublishToSM' />
<Value Type='Boolean'>True</Value>
</Eq>
<IsNull>
<FieldRef Name='SMUpdateDate' />
</IsNull>
</And>
</And>
</Where>
<BeginsWith>
<FieldRef Name='ContentTypeId' />
<Value Type='ContentTypeId'>CONTENTTYPE ID</Value>
</BeginsWith>
Set the SPSiteDataQuery's Scope property to SiteCollection. By setting the Lists property you can also limit the search to for instance document libraries etc. The ViewFields property can be set to limit the fields retrieved (i.e. instead of the equivalent of a select * on the items's fields)

How does SharePoint store the CAML for a view's filter?

I'm trying to create a CAML query for a list in SP.
I thought of using the Modify view pages to create a basic view including a filter, then use some code to examine the Query Prop of the SPView:
string t = dataList.Views["MyView"].Query;
But CAML in t does not contain any Where elements. Just the orderby
<OrderBy>
<FieldRef Name="ID" />
</OrderBy>
How does SharePoint store the CAML for view filters?
Weird.
Because if you examine built in list schema (for example tasks list schema you can find at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\TasksList\Tasks\schema.xml) there is Where clause in Query element:
<View>
*....*
<Query>
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE">
</FieldRef>
</OrderBy>
<Where>
<Or>
<Neq>
<FieldRef Name="Status">
</FieldRef>
<Value Type="Text">$Resources:core,Tasks_Completed</Value>
</Neq>
<IsNull>
<FieldRef Name="Status">
</FieldRef>
</IsNull>
</Or>
</Where>
</Query>
</View>
Oh, you may try SPCamlViewer to examine your views.

Resources