Monday, November 8, 2010

SharePoint - 401: Unauthorized downloading Infopath file with WebClient.DownloadFile

Today, I got an "401: Unauthorized" exception when calling the WebClient.DownloadFile method to download an Infopath file from SharePoint, even if I provided the correct permissions (setting the WebClient.Credentials property).

This was because of the Infopath Forms Server feature in MOSS 2007 Enterprise edition. This feature redirects to the /_layouts/FormServer.aspx page, apparently this was resulting in an Unauthorized exception.

A workaround is to add "?NoRedirect=true" to the url, like this: http://ServerName/sites/SiteCollection/FormLibrary/Form1.xml?NoRedirect=true.

More information about some Query Parameters you can use on the /_layouts/FormServer.aspx page: http://msdn.microsoft.com/en-us/library/ms772417.aspx

Monday, September 20, 2010

CRM 2011 beta - integration with SharePoint 2010 (the real stuff)

The SharePoint Solution for the integration with CRM 2011 is fixed, you can download it here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0c7dcc45-9d41-4e2e-8126-895517b4274c&displayLang=en

Some screenshots of the layout of the Sharepoint folder in CRM (looking good!):







Tuesday, September 14, 2010

CRM 2011 beta - integration with SharePoint 2010

Microsoft CRM 2011 beta is available. I was curious about the SharePoint integration in CRM 2011. Unfortunately, the Sharepoint solution delivered with the beta release wasn't working (I was getting errors "Could not load file or assembly 'Microsoft.Crm.SharePoint.CrmGridFeature' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key", a reply from Microsoft CRM Support is added, saying there are some unsigned bits - http://social.microsoft.com/Forums/en-US/crm2011beta/thread/8d195290-6bfa-4d4b-a1a9-ad21bb296ad2), hope they will post an update soon!

The SharePoint solution is required to have CRM creating Sharepoint folders automatically when adding a new record. However, it is possible to add Sharepoint locations manually to a record too. Some screenshots:













Wednesday, March 31, 2010

SharePoint 2010: CamlQuery on External List

When running a CamlQuery on an External List, we got an error "The given key was not present in the dictionary.".

Apparently you have to specify the <ViewFields> tag in the CamlQuery.ViewXml property. So you have to specify the <ViewFields></ViewFields> tag with the right fields in the ViewXml property.

For example, this will NOT work:
camlQuery.ViewXml = @"
<Method Name='ReadList'/>
<Query>
<Where>
<Contains>
<FieldRef Name='Name'/>
<Value Type='Text'>AAS</Value>
</Contains>
</Where>
<OrderBy>
<FieldRef Name='Name'/>
</OrderBy>
</Query>
</View>";


... but this will work:
camlQuery.ViewXml = @"
<Method Name='ReadList'/>
<Query>
<Where>
<Contains>
<FieldRef Name='Name'/>
<Value Type='Text'>AAS</Value>
</Contains>
</Where>
<OrderBy>
<FieldRef Name='Name'/>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name='AccountID' ListItemMenu='TRUE' LinkToItem='TRUE'/>
<FieldRef Name='Name'/>
</ViewFields>


</View>";


To find out the XML you have to use for the <ViewFields> tag, you can add a ListView webpart of your External List to a page and grab the <ViewFields> XML by opening the page in SharePoint Designer:


I read this solution here: http://blog.trivadis.com/blogs/stefanfrutiger/archive/2010/03/15/sharepoint-2010-bcs-zugriff-auf-externe-daten-aus-einer-silverlight-4-applikation.aspx. Luckely, I understand a little bit German ;-)

Saturday, January 23, 2010

Validate url to be used for a SharePoint site (replace illegal characters)


I made a function to check if a string contains illegal characters to be used as an URL for a new SharePoint site. This is useful to use when calling the Webs.Add function to programmatically create a new site in SharePoint where a user has provided the desired site url.

I took a look at the Create Site page in SharePoint. SharePoint calls a JavaScript function "IndexOfIllegalCharInUrlLeafName", which can be found in the "commonvalidation.js" on your SharePoint server. After the function call, SharePoint will check for a '+' character separately.

This is the function i've created. Illegal characters are replaced with a '-' character.


(you can download the code in a text file here)