Posts

Showing posts with the label SharePoint 2013

SharePoint 2010: How do I set the value multi select lookup column?

A seed data script I was writing required a multi value selection lookup column to be pre populated. Setting a single value is simple - use <Id>;#<Text> - and all is well. But how do you set multiple values? The solution is just as simple; use ;# as the delimiter between items. For example, you could set your column with the following: <ID1>;#<Text1>;#<ID2>;#<Text2> Semi-colon Hash (;#) is the delimiter of choice.

SharePoint 2013 Pre requisites install fail, Error: The tool was unable to install Application Server Role, Web Server (IIS) Role.

I was configuring a new development environment in Amazon Web Services and I encountered the following error message: SharePoint 2013 Pre requisites install fail, Error: The tool was unable to install Application Server Role, Web Server (IIS) Role. I tried several suggestions from Google, but to no avail. The problem was I was trying to solve an unsolvable problem. Huh? I was attempting to install  SharePoint Foundation 2013 on Windows Server 2012 R2 WHICH IS NOT SUPPORTED. I needed to install SharePoint Foundation 2013 SP1 .

How can I easily debug an email utility in SharePoint?

Image
Working with emails (especially in Timer Service jobs) can be a pain to debug. Fortunately, there are a few freely available utilities that make this chore very simple. I recently wrote a simple server that send numerous emails using the following code:                         var headers = new StringDictionary                         {                             {"from", web.Site.WebApplication.OutboundMailSenderAddress},                             {"to", user.Email},                             {"subject", subject},                             {"content-type", "text/html"}   ...

SharePoint 2013: What do the items in a claims token mean?

The code for 'All Authenticated Users' is c:0(.s|true. Its all very confusing - but everything is revealed  here

SharePoint 2013: How can I get a users SPPrincipal token?

In a SharePoint Claims authenticated environment, you need to extract the full claims token  (not just DOMAIN\Username). Here are two simple methods using the ResolvePrincipal  function to get the information: PowerShell: function GetUserPrincipalFromUsername($siteUrl, $login) { $web = Get-SPWeb $siteUrl $principal = [Microsoft.SharePoint.Utilities.SPUtility]::ResolvePrincipal($web, $login, [Microsoft.SharePoint.Utilities.SPPrincipalType]::All, [Microsoft.SharePoint.Utilities.SPPrincipalSource]::All, $null, $false) $web.Dispose() return $principal } C#: public SPPrincipalInfo GetUserPrincipalFromUsername(SPWeb web, string userName) {   return SPUtility.ResolvePrincipal(web, login, SPPrincipalType.All, SPPrincipalSource.All, null, false); }

SharePoint 2013: Error updating managed account credentials

I encountered the following message when trying to change a password for a managed account: Error deploying administration application pool credentials. Another deployment may be active. An object of the type Microsoft.SharePoint.Administration.SPAdminAppPoolCredentialDeploymentJobDefinition named "job-admin-apppool-change" already exists under the parent Microsoft.SharePoint.Administration.SPTimerService named "SPTimerV4".  Rename your object or delete the existing object. The error message is self explanatory - Rename your object or delete the existing object.  I choose the latter. Powershell to the rescue. $job = Get-SPTimerJob -Identity "job-admin-apppool-change" $job.Delete() Reset the password and all should be good.

SharePoint 2013: The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request.

This was a nasty problem to resolve. I googled it and went through some basic steps: 1. follow the suggestions from msdn blog ( here ) 2. restart the windows service but no luck. I then restarted the SharePoint Service (Central Administration -> Settings -> Services on Server) and found that the password for my managed account had expired. I ran the powershell script  Set-SPManagedAccount  to correct the problem.

SharePoint: The contents of the feature’s solution requires the Solution Sandbox service to be running

In 'System Settings' -> 'Manage Services on Server', ensure that the service 'Microsoft SharePoint Foundation Sandboxed Code Service' is running. Open a new instance of PowerShell and you are good to go ...

ShaerPoint 2013: How do I change the picture (source) for an image at runtime?

An image can easily be converted into a 'clickable' image with some simple html manipulation - put the image in an anchor tag. I have added two images (First.ico and Second.ico) to the Style Library/images of my site collection. I also have jQuery referenced in my masterpage. Here is the html: <a href="" onclick="changeImage()"><img id="favourite" ></img></a> Changing the image is just as easy: First, lets set an initial source value: jQuery(window).load(function () {    $("#favourite").attr("src", "/Style%20Library/Images/First.ico"); }) Then, implement the changeImage function to switch images: function changeImage() { if ($("#favourite").attr("src") == "/Style%20Library/Images/First.ico") { $("#favourite").attr("src", "/Style%20Library/Images/Second.ico"); } else { $("#favourite").attr(...

SharePoint 2013: How do I reference a html 'source' file from another site collection in a Content Editor Web Part?

Content Editor Web Parts are fantastic for rendering content, but there is small problem if you want to reference a file (through a ContentLink) on another site collection - you are not allowed to! Cross-site scripting is not a good thing. This problem becomes apparent when you have a 'source' site collection that will host all the html/js files and you want all other site collections to reference this (single) source of truth. There are a few options available to resolve the problem. 1. Copy all the JS/Html files to each site collection and reference them locally. (Easy, but it will create a maintenance nightmare if you have lots of site collections). 2. Enable Anonymous access to the 'source' site collection. (Easy, but not a great solution) 3. Install  Content Link Web Part  from Codeplex. (Better, but requires a Farm Solution) 4. Move the link from the ContentLink to the Content in the webpart. The key to resolving the problem is nested CDATA tags. In my ...

Sharepoint 2013: Why is my deployed dll not in the GAC?

I have created a new SharePoint wsp and it has been successfully deployed, but when I searched for the compiled component in the GAC, it was nowhere to be seen. Huh? The simple solution is that the GAC is .net 1.0 - 3.5 is not the same as the GAC in .net 4.0+. The old GAC is the trusted location c:\windows\assembly The new GAC resides in c:\windows\microsoft.net\assembly It was there after all - it helps when you look for the file in the right place.

PowerShell: How do I append data to an existing file in SharePoint with a new line and quotes?

A recent proejct required the injection of some runtime data in my require js configuration file. The following code allowed me to inject the new values into the file. $site = Get-SPSite "http://mysite" $file = $site.RootWeb.GetFile("/Style Library/myfile.js") if (($file -ne $null) -and ($file.Exists -eq $true)) { $binaryAsIs = $file.OpenBinary() $asciiEncoding = New-Object -TypeName System.Text.UTF8Encoding $asIs = $asciiEncoding.GetString($binaryAsIs)         # This is the text to append to the top.         # `r`n will create a crlf (new line)         # $([char]34) will embed a double quote in the text $new = "// Here is some next text `r`n //and here is text in $([char]34)quotes([char]34)`r`n" $newFile = $new + $asIs $binaryToBe = $asciiEncoding.GetBytes($newFile) $file.CheckOut() $file.SaveBinary($binaryToBe) $file.CheckIn("") $file.Publish("") } $site.Dispose()

SharePoint: How do I find out (quickly) if my server has a Kerberos ticket?

A new SharePoint project introduced the prospect of the dreaded 'double hop' problem and the team was looking at ways to resolve the issue. Naturally, Kerberos (and delegation) was the natural solution. However, we were not sure if the Farm and Servers had Kerberos enabled. A quick one word line command resolved the problem:  klink . This command displays a list of currently cached Kerberos tickets.

JQuery-Upload - a few ways to upload a file

I was recently using the magnificent  jQuery-File-Upload  in a SharePoint 2010 application. I encountered the following scenarios to upload files. 1. Load immediately when the file is selected This is the easiest option and is pretty much OOTB. $('#fileupload').fileupload({                 dataType: 'json',                 headers: {                     Accept: "application/json"                 },                 accept: 'application/json',                 formData: {                     url: "http://mytargetlocation",                     title: "myTitle"                 }, ...

SharePoint 2013: Configure 2013 Workflows for Sharepoint Designer

Workflows are configured a little differently in SharePoint 2013 than they are in 2010. I tried to find a good resource to take me through the installation and the best one I found was at  harbar.net A brief summation of the steps are: 1. Download workflow manager 2. Download workflow client 3. Add a binding to new web (12290 for https / 12991 for http) 4. Register the Service 5. Make sure that the port (12290/12291) is allowed as an incoming rule in the firewall. The only problem I encountered while following the installation instructions (which are excellent) was the registration if the SPWorkflowService. I found the resolution to my problem on the  Microsoft site  - my Register-SPWorkflowService command needed a –AllowOAuthHttp flag at the end.

SharePoint: How do I add and remove unique permissions in Powershell?

Here are two useful scripts to help you on your way: function SetPermission($url, $list, $group, $permission) { $spWeb = Get-SPWeb $url $selectedList = $spWeb.Lists[$list] # Assign the "Contribute" RoleDefition to the site's visitors group $visitorsSPGroup = $spWeb.Groups[$group] If (! $selectedList.HasUniqueRoleAssignments) { $selectedList.BreakRoleInheritance($true) } $assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($visitorsSPGroup) $assignment.RoleDefinitionBindings.Add(($spWeb.RoleDefinitions | Where-Object { $_.Type -eq $permission })) $selectedList.RoleAssignments.Add($assignment) $selectedList.Update() $spWeb.Dispose() } function RemovePermission($url, $list, $group) { $spWeb = Get-SPWeb $url $selectedList = $spWeb.Lists[$list] $visitorsSPGroup = $spWeb.Groups[$group] If (!$selectedList.HasUniqueRoleAssignments) { $selectedList.BreakRoleInheritance($true) } $web.AllowUnsafeUpdates = $true; ...

SharePoint 2013: HTTP 500 error when sending an email from a SharePoint Designer workflow

I recently encountered this problem for a client and the cause had me stumped. I did all the basic checking 1. Check the UPS was up to date 2. Made sure that the Workflow Manager was correctly installed 3. Made sure that the firewall was not blocking the WF manager port (12290 or 12291). Still nothing. The problem (it seems) comes from Document Library 'Advance Settings'; the document library had 'require checkout' set. I did not think anything of it, but once I removed it the workflow executed as expected. Its a strange behaviour but at least its something to look at when trying to resolve the issue.

SharePoint 2013: Can I add a document to a generic list?

Image
The short answer is yes. In the advanced settings for a list, there is an 'enable attachments' setting.

SharePoint 2013: the given key was not present in the dictionary

I have been pulling my hair out over the last few days to resolve this issue. I tried some of the suggestions: 1. make sure that the User Profile Service is up to date and make sure that a full synchronization has run. 2. make sure that the initiator accounts have access to Worflow History 3. make sure that the Doc library does not require checkout (or that your code handles it) However the real solution to my problem came from SharePoint permissions. I had overridden the base permissions the on the Workflow Tasks list and the lists hosting the workflows and it seems that this caused the problem. Once I reverted to the parents' permissions, the error disappeared. The next problem was allowing users to approve their tasks. By default, users did not have 'approve' permissions on the list, so I needed to add a little code to my 'Tasks' web part to solve the problem; I gave the current user 'contribute' permissions on the list item so it could be mode...

SharePoint 2013: How do I set a custom page to be a default page for a site?

Image
The solution is very simple; navigate to the page in SharePoint Designer 2013, right click and select 'Set as Home Page'.