CAML Query using Date Ranges

Having trouble getting any results back when querying a SharePoint list for items within a date range? It may be that you haven’t converted your variable dates to the ISO 8601 format that SharePoint expects for date values in CAML queries. You can do this by using the SPUtility.CreateISO8601DateTimeFromSystemDateTime() method. Make sure the dates you are converting are in UTC or local time first though!

An example is below:

string Iso8601startDate = SPUtility.CreateISO8601DateTimeFromSystemDateTime(startDate);

string Iso8601Today = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today.AddDays(1));

            if (spList != null)

            {

                SPQuery qry = new SPQuery();

                qry.Query =

                @”   <Where>

                          <And>

                             <Gt>

                                <FieldRef Name=’DateSubmitted’ />

                                <Value Type=’DateTime’ IncludeTimeValue=’FALSE’>” + Iso8601startDate +

                                @” </Value>

                             </Gt>

                             <Lt>

                                <FieldRef Name=’DateSubmitted’ />

                                <Value Type=’DateTime’ IncludeTimeValue=’FALSE’>” + Iso8601Today +

                                @”</Value>

                             </Lt>

                          </And>

                       </Where>

                       <OrderBy>

                          <FieldRef Name=’DateSubmitted’ />

                       </OrderBy>”;

 

 

 

Getting Values from a Multi-select People Picker in VS Workflow

If you are trying to get a value from a multi-select people picker in workflow in the same way as you would from a single select people picker, then you are going to have problems.

I came across a great post (my salvation) here:

http://sharepoint.stackexchange.com/questions/78125/workflow-sp-2013-cannot-retrieve-a-usermulti-field-value

-which saved me a lot of time and headache. But just incase  I’ve posted a screenshot below. Worked a treat for me (in this example, the multi-select people picker field is called Members).

MultiPPValueWF

Error When Creating Links List Items (Hyperlinks)

In my case, I was using PowerShell to create a bunch of links to folders on a file-share in a SharePoint list. I came across errors when I used the 2010 method in 2013. Below I have provided examples of each method:

2010

$urlValue = New-Object Microsoft.SharePoint.SPFieldUrlValue("")
$urlValue.Description = "This is an awesome description"
$urlValue.Url =  "http://MyUrl.com"
$item["URL"] = $urlValue
$item.update()

2013

$newItem = $list.Items.Add()
$newItem["URL"] = "$urlString , $descriptionString"
$newItem["Comments"] = $descriptionString
$newItem.Update()

 

Display a List Web Part View Using a Query String Parameter

So what if you want to have a single “dashboard” page that displays a number of web parts, including a list web part? You’d like to provide multiple links to the page which will display slightly different views of the information. In this case, you may want to think about using the view query string parameter in your links to change the view of the list web part displayed.

To get a list view GUID/s add the list web part to your page and filter the list. You can then look at the URL to find the GUID, e.g. https://server/sites/subsite/Shared%20Documents/Dashboard.aspx?View={CEF00598-91B2-456E-8068-F351BC9CC1BA}

Change the web part View property to access different view GUIDs. Once you have a GUID for each view, you can add the ? or & View={GUID} to your dashboard hyperlinks.

Click the hyperlinks and bingo-bango, you should see your list web part displays the relevant view. This should not effect any other web parts also on the page, as the view GUID is unique to the specific list.

 

Grouping a List View by a Calculated Date Field

If you’ve been ultra efficient and create a calculated Date Field that will display the month and year (e.g. Aug 2015) of a date column so that you can group something like News Articles in this way, you may have already discovered that grouping your list view using this new column displays the group header as blank. When you include the calculated field in your view, you see it has value BUT the won’t display in the group header.

I found a work around for this – simply edit your view and change the style to Basic Table. I also played around with default expansion of the groupings. This should now display your calc field group headings and display any items underneath.

SharePoint Wiki Updated Pages Invalid index (Exception from HRESULT: 0x80070585)

After creating a SharePoint 2013 Wiki library, the quick launch navigation under Updated Pages reports “an error has occurred on the server.” When you click on the Updated Pages link it displays the error: Invalid index. (Exception from HRESULT: 0x80070585).

This error occurs when there is no index column in your Wiki list. To fix it, add a column for indexing:

Library Settings -> Index Columns: Create a new Index on the ‘Modified’ column.

There you have it. The problem should now be solved.

Content Organiser Routing and Document Sets

You CAN route a document deposited in the Drop off library, to a document set. You wouldn’t think so considering there is no way of selecting a document set within the browse-library UI, available in the Content Organiser rules page, but there is a trick. Just type the Document set name on the end of your library URL. Don’t copy and paste from the address bar- it won’t work. Make sure, if your document set name is multiple words e.g. Shipping ABC, then use %20 for spaces – /Shipping%20ABC

Ok so now we have that out of the way, I have a complaint about the Drop off library. Even if all metadata is filled out on a “dropped document” the document won’t be routed until it’s properties are edited. That seems completely pointless! I email enabled my drop off library will all metadata fields having defaults. When a document arrived it didn’t route until I edited the properties (which were all already filled out and correct) and clicked submit.