n two days I´ve been struggling to remove a sharepoint app/addin. I´m unsure what really happened. May be a update failed, and put the app in some corrupted state. I don’t know. But the error I kept getting was:“Another job exists for this app instance. Please retry after that job is done.”

This is the step I took to resolve it.

1. The AppMng.svc service was not available. (tried to register a new app with _layouts/15/AppRegNew.aspx and get an error about that service)That in turn was because the Search Host Controller Service was stuck on starting. I resolved that one by running the script from this blog: https://mwiedemeyer.de/blog/post/Search-Host-Controller-Service-in-Starting-state

2. The metadata service was not working properly. There was one app-pool turned off in IIS, which I started.

3. I then renamed and changed the url of the site (_layouts/15/prjsetng.aspx) which hold the installed app. 

Now I was able to uninstall the app from the GUI.

I tried to copy a page from one wiki-library (SiteContent) to another library on another web site with code.

First I tried to add the file with ”wikiLibrary.RootFolder.Files.Add”, but the file become blank.

I then copied the value from the item property ”wikiField”. Now I got text, but no web parts.

Now I was about to give up, when I made a last try with moving the web parts as well. That worked!

This is the complete code:
SPWeb web = SPContext.Current.Web;

var wikiLibrary = web.Lists.TryGetList(”Webbplatssidor”);

SPWeb webTemplate = web.ParentWeb;

var templateWikiLibrary = webTemplate.Lists.TryGetList(”Webbplatssidor”);

foreach (SPListItem item in templateWikiLibrary.Items)
 SPFile newFile = wikiLibrary.RootFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
var wikiFieldName = wikiLibrary.Fields[SPBuiltInFieldId.WikiField].InternalName;
var wikiContent = item[wikiFieldName];
newFile.Item[wikiFieldName] = wikiContent;

 //Copy webparts:

var wpManagerTemplate = webTemplate.GetLimitedWebPartManager(item.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

var wpManagerNew = web.GetLimitedWebPartManager(newFile.Item.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

var webParts = wpManagerTemplate.WebParts;
foreach (WebPart webpart in webParts)

{            wpManagerNew.AddWebPart(webpart, ”wpz”, webpart.ZoneIndex);






I had problem with the Send link at the call out menu in search. The text wasn’t encoded correctly in Outlook when the link was clicked from Internet Explorer 10 (Firefox worked fine).



   The Send button is set in the Item_CommonHoverPanel_Actions display template.

More about how the item_template, HoverPanelTemplate and Actions are connected, see this blog post: http://blogs.technet.com/b/tothesharepoint/archive/2013/09/18/how-to-add-a-custom-action-to-the-hover-panel-in-sharepoint-server-2013.aspx
But instead of navigate to: site settings –> masterpages and page laouts –> Display Templates –> Search, and upload files to the library, I used SharePoint Designer.

Open the designer, open your site collection, and click: All files _catalogs —> masterpage –> Display Templates –> Search. Open the Item_CommonHoverPanel_Actions.html. Now you can edit the file, save and see the changes immediately.  

Seems like IE won’t handle the html encoding correctly. But the characters works fine without encoding, so I thought I could decode it. First I tried with the SharePoint java-method STSHtmlDecode with no luck. I then tried with the standard java-method decodeURI. That one worked!

The code was changed from the following:

<a clicktype=”ActionSend” id=”_#= $htmlEncode(id + HP.ids.send) =#_” class=”ms-calloutLink ms-uppercase” title=”_#= $htmlEncode(Srch.Res.hp_Tooltip_Send) =#_” href=”_#= $htmlEncode(emailLink) =#_”>

To this:

<a clicktype=”ActionSend” id=”_#= $htmlEncode(id + HP.ids.send) =#_” class=”ms-calloutLink ms-uppercase” title=”_#= $htmlEncode(Srch.Res.hp_Tooltip_Send) =#_” href=”_#= decodeURI(emailLink) =#_”>


So, you want to send files to another list? Well there is different approaches to that, but one is to use the built in Document routing. To set this up you need to do the following:

  1. On the site that you want your documents to be sent to (the destination), activate the Content Organizer feature.
  2. Add rules for the incoming documents. Go to: Site Settings, Content Organizer Rules, add new item. More info here: https://support.office.com/en-sg/article/Create-Content-Organizer-rules-to-route-documents-74dfe36d-e3d6-40b7-9a5c-beea0c84deed
  3. Find your “Send To URL”. Go to: Site Settings, content organizer settings. At the bottom, you find the url. Write it down.
  4. Create a send to connection. Go to: central admin, General application settings, under “External Service Connections” choose” Configure send to connections”. Enter the “Send To URL”.
  5. Done!

Now, for a file in the same web application, you can send it to the destination through GUI by selecting the file, go to the tab “file” in the ribbon, and click “Send to” and select your send to connection.

But if I would like to send all files in a list to the destination site? Could I use a workflow? There is a 2010 list-workflow action called “Send Document to Repository”. But list workflows only handles one item at a time as I understand. But if you have document sets, you can use the action “Send Document Set to Repository”. The SharePoint 2013 workflows have no action for sending files with document routing.

So for me, the only option was to send all documents with code. I did a test with powershell.

On spfile, there is a method called SendToOfficialFile (https://msdn.microsoft.com/en-us/library/office/ms440019.aspx).

It has five different overloads. I started with the more advanced methods, cause I thought that I needed to specify the destination url, and to add all properties in an array. But it turned out that I didn’t. Seems like SharePoint uses the default “send to connection” for the web application if no source is specified. All properties was also successfully submitted when I didn’t specified them either.

Here is my first try:

$siteurl = ”https://siteurl&#8221;
$spweb = Get-SPWeb -Identity $siteurl
$list = $spweb.Lists[”Document”]
$targetHost = $spweb.Site.WebApplication.OfficialFileHosts[0]
$outputResult = ””
foreach($item in $list.Items)

$propertyList = New-Object -TypeName System.Collections.Generic.List[Microsoft.SharePoint.RecordsRepositoryProperty]
$arkivtagg = New-Object -TypeName Microsoft.SharePoint.RecordsRepositoryProperty
$arkivtagg.Name = ”Arkivtagg”
$arkivtagg.DisplayName = ”Arkivtagg”
$arkivtagg.Type = ”Text”
$arkivtagg.Value = $item[”Arkivtagg”]
$recordSeries = $item.ContentType.Name
$item.File.SendToOfficialFile($recordSeries, $targetHost, $propertyList,”system@mail.se”,[Microsoft.SharePoint.SPOfficialFileSubmissionMode]::Manual, [ref] $outputResult)



Here is my last and working code (no target host, no propertie array):

$siteurl = ”https://siteurl&#8221;
$spweb = Get-SPWeb -Identity $siteurl
$list = $spweb.Lists[”Document”]
$outputResult = ””
foreach($item in $list.Items)
$item.File.SendToOfficialFile([ref] $outputResult)


I have been using the somewhat cumbersome way of change the logined user: Open the browser as a nother user.

The other day i found this article, that gave me a different approach: adding _layouts/closeConnection.aspx?loginasanotheruser=true to the web site url.

Thanks for that one!

When I try to run the august cumulative update for SharePoint 2013 standard, I get the error: ”The expected version of the product was not found on the system.”
The title of the windows says: ”Cumulative update for Microsoft SharePoint Enterprise Server 2013”. I look in this article, and there is no specific update for Enterprise. http://technet.microsoft.com/en-us/sharepoint/jj891062.aspx
I can´t find any updates for the language pack either.

I then found out that you first need to install the mars public update to be able to run any CU´s.


How do you deploy the best way?

Publicerat: oktober 9, 2013 i Uncategorized

How do you deploy the best way?
The goal is to make a deploy that affect only the parts the solution needs.
1. Primarily use sandboxed solution.
2. Secondly , deploy to the GAC , but install only the solution to affected web application (e.g. Install- SPSolution -Identity namn.wsp – GACDeployment – WebApplication Intranet )
To make this possible, sometimes you need to add a Safe Control to the project.
3. Install only globally if needed ( e.g., timer jobs or work flows ) .
Target : WebApplication vs GAC
One can select in the project in Visual Studio where a dll should be placed. Either in the GAC or in a web applications bin directory.
GAC affects the entire farm, while having a dll in the bin only affect the web application.
The problem with choosing Assembly Deployment Target: WebApplication is that a change of the trust level for the IIS site may be needed. This is a bit tricky. It requires that you create a custom policy file, and then refer to it in web.config.
Because of this, some recommend to create a sandboxed solution .




Installing to the GAC , but install solution into individual Web applications
If you only install to the gac (eg Install- SPSolution -Identity namn.wsp – GACDeployment ) the solution becomes installed globally and is accessible from all web applications.
If you add – WebApplication during installation,you can add the solution to a specific web application (eg Install- SPSolution -Identity namn.wsp – GACDeployment – WebApplication Intranet).
This may generate the following error : ”Install- SPSolution : This solution contains no resources scoped for a Web application and can not be deployed to a Particular Web application . ”
This is because SharePoint checks if the solution contains components that are specific to a Web application. If it´s not, SharePoint wants to install it globally. To get around this, you can add Safe Controls in the package.
How to do it is described here: