SharePoint 2013 Columns Sorting Order - sharepoint

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

Related

SharePoint Recurring Events Are Random?

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

Properly Nesting Compound AND / OR Statements Using CAML

I am leveraging SPservices within a SharePoint 2013 environment to create filtered views unique to the current user. Effectively, when a user visits a page, they get a custom feed of documents that they have uploaded to a specific library.
I can successfully query the library and render the results they way I want, but when I attempt to create a compound CAML query, I keep getting errors. I have tried using the various resources here to manually build this query (and do to network restrictions I cannot use the U2U CAML builder tool), but I keep getting thrown errors. I started doing simple queries and it was working, but once I try to get to my third and forth "OR" statements (including a IsNull argument), I hit a wall. I think I am improperly nesting my statements and would love some help in identifying what I am doing wrong.
<Where>
<And>
<Contains>
<FieldRef Name='Author' />
<Value Type='User'>" + userName + "</Value>
</Contains>
<And>
<Eq>
<FieldRef Name='ContentType' />
<Value Type='Computed'>Document</Value>
</Eq>
</And>
<Or>
<Or>
<Or>
<Or>
<Eq>
<FieldRef Name='sensitivity' />
<Value Type='Choice'>Low</Value>
</Eq>
<Eq>
<FieldRef Name='sensitivity' />
<Value Type='Choice'>Medium</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name='sensitivity' />
<Value Type='Choice'>High</Value>
</Eq>
</Or>
</Or>
<IsNull>
<FieldRef Name='sensitivity' />
</IsNull>
</Or>
</And>
</Where>
The desired result would be an output of items that the current user uploaded / created WHERE the Content Type is equal to "Document" AND the Sensitivity (choice) field is equal to Low, Medium, High or is empty.
I feel like I am really close, but I am making a silly mistake. For context, the "userName" reference in the statement is a javascript variable that is functioning properly.
The bracketing can be quite confusing without a tool like the U2U CAML builder tool. I feel your pain.
I think your issue may be the isnull at the end. I believe you would want is NotNull
<IsNotNull>
<FieldRef Name='sensitivity' />
</IsNotNull>
As a last ditch you might be able to just query all files by user whos documents co

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.

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