Was having an issue opening PDF files in SharePoint 2010…
What worked for me was to install Adobe Reader X.
http://www.adobe.com/products/reader.html
Was having an issue opening PDF files in SharePoint 2010…
What worked for me was to install Adobe Reader X.
http://www.adobe.com/products/reader.html
Yes, SharePoint workflows are case sensitive!
Recently ran into a BIG issue that caused thousands of emails to be sent, because of this question.
I needed to relink a few hundred InfoPath forms, the library had an associated workflow… So, I opened SharePoint Designer, added a new step to the workflow, and published my changes.
workflow step:
Condition: If Modified By equals domain\Ihayse
Action: Stop the workflow
Why do this?
When you relink the forms in a library, the worklow will be fired.
After receiving emails and IM’s from some happy campers, I knew my workflow was wrong.
My workflow step should have read:
Condition: If Modified By equals domain\ihayse
Action: Stop the workflow
My domain name is my first initial then my last name, all in lowercase.
Out of the box, the storage allocation for My Sites is real small. In SharePoint 2010 and SharePoint 2007 you can increase the storage limits for each My Site.
In SharePoint 2010:
Central Admin > Application Management > Configure quotas and locks
First select the My Site Web Application, then select the users My Site you want to edit.
In the Site Quota Information section, change Current quota template to Individual Quota, then change Limit site storage to a maximum of: ___ to your new value.
You can also set the Send warning e-mail when site storage reaches value to remind the user they are running low on space.
Click OK, and you are ready for more storage.
Microsoft info on this topic:
http://technet.microsoft.com/en-us/library/cc263480.aspx#BKMK_ChangeQuotaTemplates
Where is the Manage Content and Structure link?
Notice how the URL changes….
http://sharepoint/_layouts/sitemanager.aspx?Source=%2FPages%2FDefault%2Easpx
http://sharepoint/taco/_layouts/sitemanager.aspx?Source=%2Ftaco%2Fdefault%2Easpx
http://sharepoint/taco/meat/cheese/_layouts/sitemanager.aspx?Source=%2Ftaco%2Fmeat%2Fcheese%2F%5Flayouts%2Fmngsubwebs%2Easpx%3Fview%3Dsites%26
Ohhh how handy can PowerShell be!
I needed to change the default value of a Date and Time field for several hundred sites. PowerShell allowed me to update the field on all of my SharePoint sites in a matter of seconds.
#add-pssnapin microsoft.sharepoint.powershell $spsite=[Microsoft.SharePoint.SPSite]("http://sharepointed.com/customers/") foreach ($web in $spsite.AllWebs) { Write-Host $web.name $List = "List or Library" $OpenList = $web.Lists[$List] $Field = $OpenList.Fields["My Date Field"] $Field.DefaultValue = "[today]" $Field.Update($True) $web.Dispose() } $spsite.Dispose()
Recently was asked to update the hyperlink field in a SharePoint list. The list had thousands of links pointing to a server we were moving, so the URL in the list needed to updated to reflect the new location. The only options I could think of, were to open SQL Server and do find/update against the content database(s). Well, Microsoft doesn’t like up playing with the SharePoint databases. So I cracked open PowerShell and went to town trying to figure this out.
#Add-PSSnapin Microsoft.SharePoint.PowerShell $siteUrl = "http://sharepoint/SiteCollection/SiteName" $webName = “SiteName” $listName = "Name of your list" $spSite = new-object Microsoft.SharePoint.SPSite($siteurl) $spWeb = $spSite.OpenWeb($webName) $spList = $spWeb.Lists[$listName] foreach($Item in $spList.Items ) { $ofldurl= new-object Microsoft.SharePoint.SPFieldUrlValue($Item["URL"]) $ofldurl.URL = $ofldurl.URL.Replace("Nacho", "Taco") $ofldurl.Description = $ofldurl.Description.Replace("Nacho", "Taco") $item["URL"] = $ofldurl $item.update() } $spWeb.Dispose()
What I’m doing here is replacing part of the URL string with a new word. The script is looking for the string Nacho and replacing it with Taco.
**** update ****
After migrating from SharePoint / WSS 2007 to SharePoint 2010, we started to notice some of our URLs were messed up. Web parts ( Page Viewer) and internal hyperlinks were pointing to an incorrect location.
example:
http://sharepoint/crmsp/customers/sitename/_layouts/1033/mngsubwebs.aspx?view=sites
Notice the 1033, no bueno!
Using the script above, i was able to update the links.
#Add-PSSnapin Microsoft.SharePoint.PowerShell $siteUrl = "http://sharepoint/SiteCollection/SiteName" $webName = “SiteName” $listName = "Name of your list" $spSite = new-object Microsoft.SharePoint.SPSite($siteurl) $spWeb = $spSite.OpenWeb($webName) $spList = $spWeb.Lists[$listName] foreach($Item in $spList.Items ) { $ofldurl= new-object Microsoft.SharePoint.SPFieldUrlValue($Item["URL"]) $ofldurl.URL = $ofldurl.URL.Replace("1033/", "") $ofldurl.Description = $ofldurl.Description.Replace($ofldurl.Description, $ofldurl.Description) $item["URL"] = $ofldurl $item.update() } $spWeb.Dispose()
In SharePoint 2016, the Description property appears broken?
This is the only way I could manage to set the URL and display text:
$newItem[“LinkField”] = "http://taco.com, taco2"
Error_pagetitle
An error occurred while getting the items.
List does not exist.
The page you selected contains a list that does not exist. It may have been deleted by another user.
ErrorPageRequestGuid
This was one crazy mess!
First I tried digging around in SharePoint Designer with no luck. In Designer, when I clicked on Lists and Libraries, nothing would appear in the right window. Odd. When I clicked on All Files, all my items would appear. But, if I tried to right click on the masterpage folder I would receive and error. Then… I noticed when I tried to open the Documents library in my site it would say something like the webpage does not exist.
Onto the ULS Log Viewer.
Started up the Viewer, then made SharePoint toss that error again.
Looked in the Viewer and found that SharePoint error-ed out because of the Documents library on the site. No idea why this single library was the issue. I couldn’t open the library, so I tried to attack it with PowerShell.
$site = new-object Microsoft.SharePoint.SPSite("http://sharepointed.com/") $web = $site.rootweb $list = $web.Lists["Documents"] $list.Delete #do a .Dispose()
Ran this code, then went back into SharePoint, and tried to create a new Document Library. Shaaazam, it worked!
It worked but my Documents library was still showing up in the _layouts/viewlsts.aspx view.
Still working on this issue.
*one note.
For some reason, if I tried to access the site from a PC without SilverLight, I was able to create new Libraries.
Let me start this off by saying I’m new to PowerShell AND I’m sure someone could sum up my code in one line of code.
I was asked to provide a list of all users in a SharePoint Site Collection / Web App. The person asking this, was wanting to see each user, the site and list they had access to. More or less I needed to iterate through all the sites, loop on the user, loop again on the site, then loop on the lists.
So the layout I could provide was:
Site Collection
User Name
Site
List
I’m outputting the results to a file name UserAccess.txt on the C:\ drive.
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”) [System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”) $spsite=[Microsoft.SharePoint.SPSite]("http://sharepoint/") out-file c:\UserAccess.txt -append foreach ($Site in $spsite.AllWebs) { "Site Collection Name: $Site" | out-file c:\UserAccess.txt -append foreach ($User in $Site.SiteUsers) { "--User Name: $User" | out-file c:\UserAccess.txt -append foreach ($Site in $spsite.AllWebs) { $SitePermissions = $Site.Permissions foreach($mySitePermission in $SitePermissions) { if($User.ID -eq $mySitePermission.Member.ID) { "----Site Name: $Site" | out-file c:\UserAccess.txt -append } } foreach($myList in $Site.lists) { $myListPermissions = $myList.Permissions foreach($myListPermission in $myListPermissions) { if($User.ID -eq $myListPermission.Member.ID) { "------List Name: $MyList" | out-file c:\UserAccess.txt -append } } } $Site.Dispose() } $Site.Dispose() } }Let me know if you have any questions or need any help.
hayse ian
Microsoft was nice enough to post a code example in C#, but I’m lazy and haven’t moved away from Visual Basic.
How to encode and to decode a file attachment programmatically by using Visual C# Visual Basic in InfoPath 2010 or in InfoPath 2007
C# example:
http://support.microsoft.com/kb/2517906
VB examples:
Imports System Imports System.IO Imports System.Text Namespace InfoPathAttachmentEncoding ''' <summary> ''' Decodes a file attachment and saves it to a specified path. ''' </summary> Public Class InfoPathAttachmentDecoder Private Const SP1Header_Size As Integer = 20 Private Const FIXED_HEADER As Integer = 16 Private fileSize As Integer Private attachmentNameLength As Integer Private attachmentName As String Private m_decodedAttachment As Byte() ''' <summary> ''' Accepts the Base64 encoded string ''' that is the attachment. ''' </summary> Public Sub New(ByVal theBase64EncodedString As String) Dim theData As Byte() = Convert.FromBase64String(theBase64EncodedString) Using ms As New MemoryStream(theData) Dim theReader As New BinaryReader(ms) DecodeAttachment(theReader) End Using End Sub Private Sub DecodeAttachment(ByVal theReader As BinaryReader) 'Position the reader to obtain the file size. Dim headerData As Byte() = New Byte(FIXED_HEADER - 1) {} headerData = theReader.ReadBytes(headerData.Length) fileSize = CInt(theReader.ReadUInt32()) attachmentNameLength = CInt(theReader.ReadUInt32()) * 2 Dim fileNameBytes As Byte() = theReader.ReadBytes(attachmentNameLength) 'InfoPath uses UTF8 encoding. Dim enc As Encoding = Encoding.Unicode attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength - 2) m_decodedAttachment = theReader.ReadBytes(fileSize) End Sub Public Sub SaveAttachment(ByVal saveLocation As String) Dim fullFileName As String = saveLocation If Not fullFileName.EndsWith(Path.DirectorySeparatorChar.ToString()) Then fullFileName += Path.DirectorySeparatorChar End If fullFileName += attachmentName If File.Exists(fullFileName) Then File.Delete(fullFileName) End If Dim fs As New FileStream(fullFileName, FileMode.CreateNew) Dim bw As New BinaryWriter(fs) bw.Write(m_decodedAttachment) bw.Close() fs.Close() End Sub Public ReadOnly Property Filename() As String Get Return attachmentName End Get End Property Public ReadOnly Property DecodedAttachment() As Byte() Get Return m_decodedAttachment End Get End Property End Class End Namespace
Imports System Imports System.IO Imports System.Text Imports System.Security.Cryptography Imports InfoPathAttachmentEncoding Namespace InfoPathAttachmentEncoding ''' <summary> ''' InfoPathAttachment encodes file data into the format expected by InfoPath for use in file attachment nodes. ''' </summary> Public Class InfoPathAttachmentEncoder Private base64EncodedFile As String = String.Empty Private fullyQualifiedFileName As String ''' <summary> ''' Creates an encoder to create an InfoPath attachment string. ''' </summary> ''' Public Sub New(ByVal fullyQualifiedFileName As String) If fullyQualifiedFileName = String.Empty Then Throw New ArgumentException("Must specify file name", "fullyQualifiedFileName") End If If Not File.Exists(fullyQualifiedFileName) Then Throw New FileNotFoundException("File does not exist: " + fullyQualifiedFileName, fullyQualifiedFileName) End If Me.fullyQualifiedFileName = fullyQualifiedFileName End Sub ''' <summary> ''' Returns a Base64 encoded string. ''' </summary> ''' String Public Function ToBase64String() As String If base64EncodedFile <> String.Empty Then Return base64EncodedFile End If ' This memory stream will hold the InfoPath file attachment buffer before Base64 encoding. Dim ms As New MemoryStream() ' Obtain the file information. Using br As New BinaryReader(File.Open(fullyQualifiedFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) Dim fileName As String = Path.GetFileName(fullyQualifiedFileName) Dim fileNameLength As UInteger = CUInt(fileName.Length) + 1 Dim fileNameBytes As Byte() = Encoding.Unicode.GetBytes(fileName) Using bw As New BinaryWriter(ms) ' Write the InfoPath attachment signature. bw.Write(New Byte() {&HC7, &H49, &H46, &H41}) ' Write the default header information. bw.Write(CUInt(&H14)) ' size bw.Write(CUInt(&H1)) ' version bw.Write(CUInt(&H0)) ' reserved ' Write the file size. bw.Write(CUInt(br.BaseStream.Length)) ' Write the size of the file name. bw.Write(CUInt(fileNameLength)) ' Write the file name (Unicode encoded). bw.Write(fileNameBytes) ' Write the file name terminator. This is two nulls in Unicode. bw.Write(New Byte() {0, 0}) ' Iterate through the file reading data and writing it to the outbuffer. Dim data As Byte() = New Byte(64 * 1024 - 1) {} Dim bytesRead As Integer = 1 While bytesRead > 0 bytesRead = br.Read(data, 0, data.Length) bw.Write(data, 0, bytesRead) End While End Using End Using ' This memorystream will hold the Base64 encoded InfoPath attachment. Dim msOut As New MemoryStream() Using br As New BinaryReader(New MemoryStream(ms.ToArray())) ' Create a Base64 transform to do the encoding. Dim tf As New ToBase64Transform() Dim data As Byte() = New Byte(tf.InputBlockSize - 1) {} Dim outData As Byte() = New Byte(tf.OutputBlockSize - 1) {} Dim bytesRead As Integer = 1 While bytesRead > 0 bytesRead = br.Read(data, 0, data.Length) If bytesRead = data.Length Then tf.TransformBlock(data, 0, bytesRead, outData, 0) Else outData = tf.TransformFinalBlock(data, 0, bytesRead) End If msOut.Write(outData, 0, outData.Length) End While End Using msOut.Close() Return InlineAssignHelper(base64EncodedFile, Encoding.ASCII.GetString(msOut.ToArray())) End Function Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T target = value Return value End Function End Class End Namespace
Imports InfoPathAttachmentEncoding
Public Sub btnAttach_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs) Dim ns As XmlNamespaceManager = Me.NamespaceManager Dim xnMain As XPathNavigator = Me.MainDataSource.CreateNavigator() Dim xnAttNode As XPathNavigator = xnMain.SelectSingleNode("/my:myFields/my:theAttachmentField", ns) Dim xnFileName As XPathNavigator = xnMain.SelectSingleNode("/my:myFields/my:theAttachmentName", ns) 'Obtain the text of the filename node. Dim fileName As String = xnFileName.Value If fileName.Length > 0 Then 'Encode the file and assign it to the attachment node. Dim myEncoder As New InfoPathAttachmentEncoder(fileName) 'Check for the "xsi:nil" attribute on the file attachment node and remove it 'before setting the value to attach the filerRemove the "nil" attribute If xnAttNode.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance") Then xnAttNode.DeleteSelf() End If 'Attach the file xnAttNode.SetValue(myEncoder.ToBase64String()) End If End Sub
Public Sub btnSave_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs) 'Create an XmlNamespaceManager Dim ns As XmlNamespaceManager = Me.NamespaceManager 'Create an XPathNavigator object for the Main data source Dim xnMain As XPathNavigator = Me.MainDataSource.CreateNavigator() 'Create an XPathNavigator object for the attachment node Dim xnAttNode As XPathNavigator = xnMain.SelectSingleNode("/my:myFields/my:theAttachmentField", ns) 'Obtain the text of the node. Dim theAttachment As String = xnAttNode.Value If theAttachment.Length > 0 Then Dim myDecoder As New InfoPathAttachmentDecoder(theAttachment) myDecoder.SaveAttachment("----------ENTER THE PATH HERE-----------") End If End Sub