I'd like to have a CAML query to get the events from a calendar list.
I want to get all the events including Today in the upcoming 30 or so days.
So far I have:
<Where>
<DateRangesOverlap>
<Geq>
<FieldRef Name=\"EventDate\" />
<Value Type=\"DateTime\">
<Today />
</Value>
</Geq>
<FieldRef Name=\"EndDate\" />
<FieldRef Name=\"RecurrenceID\" />
<Value Type=\"DateTime\">
<Month />
</Value>
</DateRangesOverlap>
</Where>
This does not work :( Any ideas?
As Nat has said you hint (but don't specify) that you are using recurring events in your calendar list so I am assuming that is the part that's not working?
You need to set the SPQuery.ExpandRecurrances and SPQuery.CalendarDate property prior to running the CAML query and you can only do this using the object model, not the web services or by setting an attribute in CAML.
Further - IIRC this will only expand out instances of recurring events that occur in the same calendar month as .CalendarDate so you have to run it multiple times to get a multi-month view.
This is by far the best reference covering recurring events I have found.
Understanding the SharePoint Calendar and how to export it to iCal format
Welcome to the nightmare of recurring events in SharePoint!
The recurrence does not actually add all the events into the list, but the CAML can only query from "actual" events stored in the list.
Related
I have an SSRS report that uses the SharePoint List data connection. It works just fine using the query below. I want a Data Driven Subscription to email the report to the user whose email address shows in the report. The problem is that a user can show up multiple times in the same run of the report and SSRS seems to want to send them an email for each time their email address shows up. I used to do this all the time with reports that used standard t-SQL using Select Distinct but this xml based query language doesnt seem to have such a function.
Does anyone have any ideas about how to either get SSRS to be smart enough to send only one email per person OR get a variation on this query to only return each email address once?
Thanks
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ListName>SSRS_Subscriptions</ListName>
<ViewFields>
<FieldRef Name="Title" />
<FieldRef Name="count" />
<FieldRef Name="eMail" />
<FieldRef Name="Org" />
</ViewFields>
<Query>
<Where>
<Gt>
<FieldRef Name="count" />
<Value Type="Number">0</Value>
</Gt>
</Where>
</Query>
</RSSharePointList>
I've created a View and did group by on a field and then did count on that field. It gives me all records and the total counts. I want to show only records which are greater than 1.... where to put this Greater than in the code ?
I created the view and I opened the view in SharePoint designer and my code looks like this now? I want to put somewhere count(Commitment_x0020_Reference) > 1
<XmlDefinition>
<View Name="{358474DF-DB87-423E-A795-6C361A33655F}" MobileView="TRUE" Type="HTML" DisplayName="Double SI" Url="/networks/SCP/Lists/Contracts and Studies/Double SI.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=23" >
<Query>
<GroupBy Collapse="TRUE" GroupLimit="500">
<FieldRef Name="Commitment_x0020_Reference"/>
</GroupBy>
<OrderBy>
<FieldRef Name="Date_x0020_of_x0020_Reception" Ascending="FALSE"/>
<FieldRef Name="Modified" Ascending="FALSE"/>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="ID"/>
<FieldRef Name="Edit"/>
<FieldRef Name="Type_x0020_of_x0020_Procedures"/>
<FieldRef Name="Unit"/><FieldRef Name="Reference"/><FieldRef Name="Title1"/><FieldRef Name="_x0039_i_x002d_Com_x0020_L2_x002"/><FieldRef Name="Modified"/><FieldRef Name="Editor"/><FieldRef Name="_UIVersionString"/>
</ViewFields>
<RowLimit Paged="TRUE">50</RowLimit>
<Aggregations Value="On">
<FieldRef Name="Commitment_x0020_Reference" Type="COUNT"/>
</Aggregations>
<JSLink>clienttemplates.js</JSLink>
<XslLink Default="TRUE">main.xsl</XslLink>
<Toolbar Type="Standard"/>
</View>
The short answer is that you can't. Querying by the sum of grouped results is not possible with a single CAML query.
Alternate options would be to perform post-processing on the results, so the query returns all records, then you remove the unwanted records on the client side, such as with JavaScript; or you could perform multiple queries in sequence to retrieve every possible value for Commitment_x0020_Reference, then perform multiple queries using those values to retrieve and count the number of results for each Commitment_x0020_Reference value.
Neither of those options is very straightforward to implement from the SharePoint Designer GUI, and may warrant a separate Stack Overflow question depending on your approach.
I have a Infopath form, published to Sharepoint 2013, in which user selects exactly one person, using a people picker. Outside of form I have columns DisplayName and AccountID. I want user, who is viewing a list, to see only objects which are either modified by him, created by him, or if he was selected in form.
Trying to limit the view from browser-based view creator is most probably impossible, as neither of columns available outside are of type User. I then moved to Sharepoint Designer 2013, and dived into CAML. This did not help either.
How can I check, if currently logged user is the same user, as the one selected in form? I tried using CAML, but to no effect(last FieldRef is reference to column, in this example AccountID).
<Where>
<Or>
<Or>
<Eq>
<FieldRef Name="Editor"/>
<Value Type="Integer">
<UserID Type="Integer"/>
</Value>
</Eq>
<Eq>
<FieldRef Name="Author"/>
<Value Type="Integer">
<UserID Type="Integer"/>
</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_638fe3aa_9161_4aa5_8bd1_862678d9fc06"/>
<Value Type="Integer">
<UserID Type="Integer"/>
</Value>
</Eq>
</Or>
</Where>
If this can be achieved from code in Infopath, or in any other way, the answer will be as well accepted - I do not want exactly CAML based answer, I want any workable answer to my problem :)
A simple filter in the view for each of the columns you would like to filter on set to [Me] should show logged in users only people picker values that are equal to themselves.
If the field in the form is a people picker then you must be storing the user data in a column somewhere unless you are discarding the data after processing it using a rule to update other fields. If that is the case, I don't see why you can't keep the people picker data stored in a column that you don't display in the view. You do not have to base the filter off of a field you are actively displaying for it to work and you are already using the right type of control to get the data you need.
Created By and Modified By columns are always user values.
I'm creating an iOS app that queries a Sharepoint Webservice with GetListItems. I'm able to retrieve all of the records, but there are a lot of records > 4000. Is there a way I can retrieve 50 at a time?
I'm using SOAP for this by the way.
Assuming you're passing a CAML query to the webservice, you ca use a rowlimit tag
<Query>
<!-- your current query here -->
<RowLimit>100</RowLimit>
</Query>
EDIT
To retrieve a subset of values you could do something like this
<Query>
<Where>
<And>
<Geq>
<FieldRef Name='ID'/>
<Value Type='Counter'>0</Value>
</Geq>
<Lt>
<FieldRef Name='ID'/>
<Value Type='Counter'>100</Value>
</Lt>
</And>
</Where>
</Query>
I haven't tested this, but it should work. Of course, you're going to want to change the values in your code to retrieve the particular subset.
I am now working on sharepoint CAML query. to fetch out item by a given name from a huge resources library which full of images, documents, videos and so on.
I didn't know whether sharepoint index the Name column. I'm thinking to use nested query to make this query faster.
My question here is:
How does sharepoint query work? execute the outer layer first, or start from the inner layer?
I wanna to filter the ResourceType(Image,Document..) first. then filter the category and finally fetch out the items match the name.Is the query bellow work just like what i need?
<Where>
<And>
<Eq><FieldRef Name='IR_ResourcesType' />
<Value Type='Text'>Image</Value></Eq>
<And>
<Eq><FieldRef Name='IR_Category' />
<Value Type='Text'>All</Value>
</Eq>
<Eq>
<FieldRef Name='FileLeafRef' />
<Value Type='File'>aaa</Value>
</Eq>
</And>
</And>
</Where>
If you can, try indexing one of the unique columns in your list so you can use it later on for querying in your where clause.
As best practice, we should also just get the columns that we will be using so as to not have a data buffet. You can limit the columns you will be displaying by using viewFields.
Here is a link which shows some tips and tricks for CAML in conjunction with SPServices which I think you might find useful.