Thursday, November 21, 2013

Attach a Document from SharePoint or Office 365 in Outlook

  • You would like to attach a document to an Outlook email that you have located within SharePoint or Office 365.
  • Note that for internal documents, you should always just link to the document in SharePoint.  Only when sharing with a user who doesn’t have access to your SharePoint site should you send a document as an attachment.
    • You can still use the following to get the link to the document.
  • You don't want to have to download it and then attach it from you local file system first
  • In addition to being able to email attachments directly from MS Word, you can attach the file directly from Outlook using the SharePoint shortcut as follows
  • Right-Click Document Name (This works from anywhere in SharePoint, even search results)
  • Select Copy Shortcut (This puts the Link to the Document in your clipboard)


  • Open the email you wish to attach to
  • Select Attach File 
    • If the recipient does have access to this document in SharePoint, you should just paste the link into the email instead, increasing security and avoiding change management issues.


  • Paste the shortcut into the File name field (Right click and select Paste or use Ctrl-V)


  • Click Insert and finish composing the Email


Friday, November 15, 2013

Unable to display this Web Part. SharePoint Designer modified XSLTListViewWebPart

  • A list or library view in the farm has ben modified in SharePoint Designer 2010
  • SharePoint Server 2010
  • An app pool recycle occurs (usually due to automatic nightly app pool restart)
  • You get the "Unable to display this Web Part." error message on any modified view.
  • SP Logs for the correlation id contain the following:
    • Failed to cache field with id "{GUID}", overwrite=0
    • Error while executing web part: System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeMethodInfo' to type 'System.Type'.     at Microsoft.Xslt.MethodCollection.MethodDescription.DeclareDynamicMethod(MethodCollection methodColl)     at Microsoft.Xslt.MethodCollection.CreateDynamicMethods()     at Microsoft.Xslt.MethodCollection.GetMethodInfoInternal(Int32 methodNumber)     at Microsoft.Xslt.MethodCollection.GetMethodInfo(Int32 methodNumber)     at Microsoft.Xslt.STransform.GetCompiledTransform()     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.LoadXslCompiledTransform(WSSXmlUrlResolver someXmlResolver)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXslCompiledTransform()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform)
  • This seems to be a Microsoft bug and only occurs after occasional app pool resets
  • IIS Reset
  • Open the view in SharePoint designer and save

Thursday, November 14, 2013

Event Receiver AfterProperties Choice field null bug

  • You are developing an event receiver where you are evaluating the AfterProperties value of an SPFieldChoice column.
  • The column's internal name does not match the display name.
  • The AfterProperties value for this field always return null/nothing.
  • MS oddly decided that this field should utilize the Title instead of the InternalName for the AfterProperties Key.  I have not verified this with the BeforeProperties, but wouldn't be surprised if it's the same.
  • Following is the code I used to workaround this:

Dim afterObj As Object = properties.AfterProperties(field.InternalName)
If afterObj Is Nothing AndAlso TypeOf field Is SPFieldChoice Then

  'Microsoft Bug that choice field uses Title instead of InternalName on AFterProperties.
  'Checks for null value first in case MS fixes this later and to reduce overhead.
  afterObj = properties.AfterProperties(field.Title)
End If