Tuesday, August 25, 2015

The Big SharePoint 2016 Resource list ...

The SharePoint 2016 preview is now officially out! That means we all have a new shiny toy to play with! What's new? Where to start and how do you get going? This post will attempt to keep up with the stream of posts that are coming out almost hourly.

(If you have written an article, please leave it in the comments and we will add it to here).

Microsoft based articles : 

Community based articles : 


by Mark Jones via Everyone's Blog Posts - SharePoint Community

Monday, August 24, 2015

How Soon Will You Start Testing SharePoint 2016 Preview?

The SharePoint 2016 Preview has been released! In August, as promised by Microsoft! There is a lot of pent-up demand for this preview (downloadable here). How eager are you to test it out? Let us know by participating in our most recent poll.


by via SharePoint Pro

SharePoint Countdown ... Wait! SharePoint 2016 Preview Is Here!

SharePoint 2016 Preview makes its August release deadline.

read more


by via SharePoint Pro

SharePoint 2016 Preview: The Countdown Continues

At SharePoint Fest Seattle last week, Microsoft's Bill Baer assured the crowd gathered for his keynote that the SharePoint 2016 was coming. As promised. In August. And, yes, Microsoft is well aware of how many days are left in August.

read more


by via SharePoint Pro

Friday, August 21, 2015

Thursday, August 20, 2015

Is it that difficult to read a file from SharePoint site?


Looks like a silly question. But it took me two hours to solve.
- I faced an issue while downloading a file... not from the browser, though.
My requirement was to read the data from an excel file that is stored in a document library. BTW, I was using OpenXML libraries to parse the excel data, which requires either the path of the file or the stream as a parameter. Since it is not possible to provide the path of a document that was stored in a library, I had to pass the stream as the argument.
Exactly here I encountered an issue when I tried to read the file as stream.
The name of the issue is... "NetworkStream", one of the least discussed class.
A Brief History of "NetworkStream":
It inherits from 'System.IO.Stream'. And so the methods derived in it.
However, it denies any seek operation we ask for. In fact this is the first time
I found this class.
        
// The below statement returns the NetworkStream Object
// fileInfoObject is of type - Microsoft.SharePoint.Client.FileInformation
var stream = fileInforObject.Stream;

As per the documentation, it should return a standard stream. But it returns a stream object that doesn't support any Seek operations(Length, Seek ..etc). Read here.. for the info.

In fact I tried couple of methods I found over the internet and found them of no use.
As a result of the experiments, I was left with a corrupted stream object saved to disk as a file that scolded me very badly, in machine language, when I tried to open it. Then, further search awarded me with a way to deal with the file - using the System.Net.WebClient class that provides methods for sending data to and, in my case, receiving data from a resource identified by a URI.

So, it is an easy operation as shown below when we want to get the file as stream from a site that readily authenticates us with the identity used to run the code.
Here, for authentication purpose, we can assign either NetWorkCredentials object or CredentialCache.DefaultCredentials to the WebClient.Credentials;

using (WebClient webClient = new System.Net.WebClient())
{
// excelFileUrl - path/url of excel file that is uploaded to a document library
Stream streamObject = webClient.DownloadData(excelFileUrl)
// now I can do anything with this stream - such as...
// 1. Saving to disk;
// 2. Passing as an argument to OpenXML library method to parse it.
}

It would have been end of this post if my struggle ended here. However, my actual requirement is to read the data from Office 365 SharePoint site. Here the problem is the 'Authentication'. Since our request doesn't carry any authentication tokens/cookies, the server rejects the request saying we don't have access. Here I tried to use my brain but it hardly paid off. The method I tried..


webClientObj.Credentials = sharePointOnlineCredentialsObject;

When I observed the request pattern using fiddler, I found that no FedAuth cookie is associated with the request. Then again google helped me. The solution is to make the WebClient class as Cookie aware. That is, to associate the WebClient with a cookie container that gets added the authentication cookies when we pass valid credentials.
The below method describes how to make WebClient cookie aware. We do a series of steps as..
1. Adding a cookie container to the child class - it helps storing the authentication cookies
2. Overriding the GetWebRequest method - it makes the web request associated with an authentication cookie as a header
3. while overriding, we add the UserAgent string to the web request -

In the absence of the UserAgent string, cookie will not get added to the container. By adding it, our web request mimics a request sent by a browser. This is any valid UserAgent string - need not be the one I've given below.

// Method [1]
// This class extends the capabilities of the WebClient class by adding
// a CookieContainer to it.
class AuthenticatedWebClient : System.Net.WebClient
{
public System.Net.CookieContainer WebClientCookieContainer { get; private set; }
public AuthenticatedWebClient()
{
WebClientCookieContainer = new System.Net.CookieContainer();
}
protected override WebRequest GetWebRequest(Uri url)
{
var request = (HttpWebRequest)base.GetWebRequest(url);
//Adds the existing cookie container to the Request
request.CookieContainer = WebClientCookieContainer;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.0; rv:12.0) Gecko/20100101 Firefox/12.0";
return request;
}
}

Now the downloading part - The below snippet tells how to pass credentials along with the Cookie aware WebClient class. We pass credentials, using the NaveValueCollection object, to the login url of the Office 365 site.

using (AuthenticatedWebClient authenticatedWebClient = new AuthenticatedWebClient())
{
System.IO.Stream filestream = null;
var values = new NameValueCollection{{ "username", "saratchandra@myorganization.com" },{ "password", "mypassword" }};
authenticatedWebClient.UploadValues("http://ift.tt/1sRvdjz", values);
string url = "http://ift.tt/1EGJcQC";
byte[] content = authenticatedWebClient.DownloadData(url);
filestream = new System.IO.MemoryStream(content);
// The below code is a custom helper method to parse the excel data
OpenXmlExcelHelper.GetExcelData(filestream);
}

With the method explained above, everything seemed to be under control. However, the result again was an incomplete chunk of byte stream - which again is not useful.

This time I really had to use my brains and...this time it worked.. The below is the code snippet for that. A simple way of making a WebClient cookie aware without struggling much.
Here, the `credentials` object is of type - SharePointOnlineCredentials

// Method [2]
using (WebClient webClient = new System.Net.WebClient())
{
webClient.Headers.Add("Cookie", credentials.GetAuthenticationCookie(new Uri("http://ift.tt/1JuEq08")));
string url = "http://ift.tt/1EGJcQC";
byte[] content = webClient.DownloadData(url);
filestream = new System.IO.MemoryStream(content);
// custom method to parse excel data
OpenXmlExcelHelper.GetExcelData(filestream);
}
Original Post

by Saratchandra Peddinti via Everyone's Blog Posts - SharePoint Community

Creating Content Types with Workflows

My first blog post EVER! :D (so please pardon any blog post etiquette that I may not follow... guess stating that this is my first blog post ever would be one of those?)

So about 3 weeks ago, I was working with a co-worker on creating a Nintex Workflow for Office 365.  The Nintex workflow will start once a user creates a Custom Folder Content Type and fills out a few metadata.  The workflow will then perform the following actions:

1.  Create a bunch of subfolders within this new folder, and set the metadata that was entered by the user.

2.  Create some documents based on a few Custom Document Content Types (mostly Word docs, based on .dotx), and set the metadata tags that was entered by the user.

We then tried to open the Custom Document Content Types that were created, and we were able to both view it with Word Online and in the Word client.  

We then demo it to users for an application that they need it for.

Two days after the meeting, we went to create more tests by creating a bunch of Custom Folder Content Type... and as expected, it created the sub folders, the documents within each subfolders, and all the metadata were set on both folders and documents.  It was then that we noticed that the documents can no longer be viewed online and got the following error:

We then tried to open the document in Word (client), which it did open but was completely blank!

Short end of it.... we contacted MS SharePoint online support... it's been escalated to 3 different levels... they were able to recreate this problem with just using SharePoint Designer (which I already tested out myself before contacting MS Support), and then offered the following solution:

"I did a bunch of testing with this and found that I was able to get a 2010 workflow to successfully create documents so long as I use a .docx file (and not a .dotx).  I’ll detail out my repro steps below for reference.  If you’d like, rather than doing steps 3-5 you could just modify the default template from a .dotx to a .docx, but either should get you to the same spot with a 2010 workflow.  Will using a 2010 workflow fit your needs?  Either way, I’m interested in the scenario that this might be used – if you shed some light there I might be able to offer some additional suggestions/alternatives."

  1. Create new library
  2. Library settings > advanced settings > enable management of content types
  3. Create new ctype at the site level
  4. Add customized word document template – test.docx
  5. Associate new ctype to my library
  6. Create new 2010 workflow in SPDesigner
  7. Add single step to create a new item in the current list – make sure my ctype is selected & give it a title.
  8. Publish & run the workflow
  9. Word doc is generated as expected & opens in both the client & web app

The problem with the above solution is that we used Nintex Workflow, which uses the 2013 workflow, and there is no option to select using a 2010 workflow.  Sure, I guess I can just recreate this in SPD with 2010 workflow, but that doesn't solve why it all of the sudden stopped working with 2013 workflow!

Anyhow, this is still not resolved but will keep you posted with any updates.


by Suolon via Everyone's Blog Posts - SharePoint Community