CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Category Archives: sharepoint

Add Search Verticals by code

search-verticals-001

Adding own search verticals is a common task in the Search Configuration in SharePoint. Here I want to share a code sample for achieving this programmatically. I hope, this model can be added to SPMeta2.

First of all, Search Verticals are dedicated Search Results Pages and links to them. How to add them manually is described on technet:

There is no API in CSOM for that. Luckily, Mikael Svenson found how to get the Search Navigation and contributed to PnP by writing an Extension: web.LoadSearchNavigation.

Here is my sample code for adding new Search Verticals programmatically:

NavigationNode searchNav = context.Web.Navigation.GetNodeById(1040);
NavigationNodeCollection nodeCollection = searchNav.Children;
NavigationNodeCreationInformation everything = new NavigationNodeCreationInformation
{
    Title = "Everyting",
    Url = "/search/Pages/results.aspx",
};
NavigationNodeCreationInformation myresults = new NavigationNodeCreationInformation
{
    Title = "My Results",
    Url = "/search/Pages/myresults.aspx",
};
nodeCollection.Add(everything);
nodeCollection.Add(myresults);
context.ExecuteQuery();
Advertisements

What is a SharePoint application

SharePoint Artefacts in a meaningful assembly like a lego toy

A meaningful collection of Lego bricks is a toy. A meaningful collection of Lists, Fields, Files and other SharePoint artefacts becomes a SharePoint Application. Private picture.

App, Add-In, List, Web, Site, Sandbox solution, Workflow. There are too many words flying around in SharePoint that confuse users and Non-SharePoint-Developers. I want to introduce a “new” concept that is so simple and that a company can understand and govern: a SharePoint Application.

That is so simple. It can be called a tool, a functionality. That can be a SharePoint list, a document library with a workflow, or a document library with custom jslink. All they can be SharePoint Applications. Let’s use lego as a metaphor. Have you seen this?

SharePoint Artefacts as lego bricks

The same toy car in just brics. SharePoint Artefacts like Webs, Lists, Fields, Content Types, JSLink etc are just lego bricks. Private picture.

These lego bricks together become a cool toy that you can play with (as you can see in the picture above). So it is with SharePoint Applications, too. SharePoint Applications solve actual business needs. A List, or a JSLink by themselves do not solve a business need. It must be a meaningful collection of SharePoint Artefacts that becomes a SharePoint Application.

Example

Does the lego metaphor make sense to you? To go back to SharePoint, I’ll give you an example of a SharePoint Application. I would say everybody has done such Applications. In a project we created a document library for product icons that were used for all products in a company. Easy? Yes. But the icons had several states (active, inactive…). Versioning and Approval was required. A workflow for new requests and submits was implemented, too, permissions for different roles, metadata navigation in the document library and so on. Sure, SharePoint provided us with great “lego bricks”. But we created a tool, a functionality – a SharePoint Application, that makes sense to our business.

What’s new then? Well, we all have done such applications. The new is to understand SharePoint Applications as an own alternative and quality assurance. See more below.

Another example is an “App” for SharePoint Online that I converted into a SharePoint Application by adjusting it for SPO and OnPrem. That’s when I came up with the idea of the SharePoint Application.

Definition

A SharePoint Application is a meaningful collection of SharePoint Artefacts, like Webs, Lists, Fields, Views etc that becomes an entity and solves a business need. SharePoint Applications follow best practices and quality policies as all other applications.

To understand more, let’s compare with the related concepts:

SharePoint Application vs SPList

An SPList (an “app”) is often only a part of an entity. Users often create two or more lists, update views and so on. A SharePoint Application contains a list and everything else ready for satisfying business needs.

SharePoint Application vs. SharePoint Hosted App (Add-In)

An SP Hosted App resides in a different domain, it is a subsite that is only trusted to do some predefined actions. An SP Hosted App allows separation of trust, it can be uninstalled easily and it is always a separate site (Web). A SharePoint Application is more flexible (it might be a list in the same site). It is closer to the actual site where users need this functionality. A SharePoint Application is in the same domain name and has the full user trust. A SharePoint Application does not require App Infrastructure and separate domains. It is searchable and can benefit from BlobCache (Style Library) to ensure good web performance.

SharePoint Application vs. Provider Hosted App (Add-In)

SharePoint Application uses SharePoint Templates, Information Architecture, Search, Identity Management etc. A Provider Hosted App is a dedicated web application outside SharePoint. A Provider Hosted Application is powerful because it is not bound to SharePoint. All advantages and disadvantages are the same as the ones for a custom ASP.NET application. A Provider Hosted App has a connection to SharePoint, it requires a Trust and App Infrastructure in your environment. A SharePoint Application is not that powerful, but as long your business need can be solved by SharePoint lists, Page Layouts, Workflows, then a SharePoint Application is the right choice for you.

Quality and Governance

To ensure quality, every SharePoint application should comply with policies and fit into the overall Govenance model. Treat them as they were other Applications. They must have system documentation, application lifecycle management including versions, upgrades and rollbacks. They must be staged and tested before going to production. Another example of a quality policy is that a SharePoint Application is provisioned, maintained and operated using only Client Side Object Model – no farm solutions. All SharePoint Applications are tracked in a system for a better supportability.

Provisioning Framework for SharePoint Applications

I would strongly recommend using a framework for provisioning your SharePoint applications. My favourite is SPMeta2. There is also PnP which is a strong community. It might be okay with manual setups (click-click in SP) for smaller applications. My advice, though: Require code based, repeatable, code-documented and tested provisioning of SharePoint Applications even for smaller ones.

Summary

SharePoint Applications have been around for a long time. My goal is to give them a name so we don’t need to be confused by apps, add-ins, lists. A SharePoint Application is not a technical term, it is just a meaningful solution for a business need, done in SharePoint that leverages high quality by following policies and standards within a company.

Http to Https Redirect in Provider Hosted Apps

It is strongly recommended to use https in SharePoint Provider Hosted Apps. In many provider hosted apps I have seen, only https works. I would recommend to configure a simple http to https redirect in IIS and make solutions better. Many Provider Hosted Apps can be done in that way that they are available without SharePoint Context, e.g. for browsing information. In that case that is important to have an easy url and an automatic http -> https redirect.

In this post I’ll give a short manual for doing that. I would recommend this step for all provider hosted apps.

1. In the Provider Hosted Apps Server install the URL Rewrite IIS Module using Web Platform Installer:

http-https-001

2. Next step is to add the http binding to your solution (this is needed for the future redirect):

http-https-004

Then you can configure the automatic http to https redirect using the GUI or the web.config update. My instructions originally come from JPPInto.com blog.

I suggest updating the web.config file directly in the Provider Hosted App:

http-https-002

3. Add this section to the web.config file:

http-https-003

<system.webServer>
  <rewrite>
   <rules>
    <rule name="Redirect to HTTPS" stopProcessing="true">
     <match url="(.*)" />
      <conditions>
       <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
    </rule>
   </rules>
 </rewrite>
</system.webServer>

It is important to know that his web.config section will cause failure on the server if URL Rewrite module is not installed.

Summary

These steps are very easy to accomplish and I recommend it for every Provider Hosted App, especially those ones that are accessible without going through SharePoint (Web Content -> Apps). This also reflects the configurations in Azure Apps (WebSites).

Kom igång med SPMeta2

SPMeta2 (eller bara M2) är ett relativt nytt ramverk för provisionering av SharePoint-artefakter. Bakom ramverket ligger ett gediget arbete. I den här posten vill jag skriva upp mina steg för att sätta upp ett litet projekt. För mig är SPMeta2 nytt och huvudprincipen i den här bloggposten att få en fungerande lösning så snabbt som möjligt. Informationen här kan snabbt bli inaktuell, eftersom SPMeta2 förändras och förbättras väldigt snabbt.

Vad är SPMeta2
SPMeta är ett ramverk för att provisionera SharePoint-artefakter, allt från fält, innehållstyper, listor, dokumentbibliotek, user custom actions, ladda upp filer med mera. Klassiskt har vi gjort provisionering med hjälp av XML-baserade moduler och features. SPMeta2 erbjuder ett Fluent API som är kodbaserat. Med hjälp av SPMeta2 definierar man en modell (enkla objekt POCOs) som inte har beroendet till SharePoint. Modellen används sedan av Provision-delen som anropar modellen för specifika versioner: SharePoint 2013, SharePoint 2010, Office 365 med mera. Man kan välja CSOM och SSOM. Provision är också flexibel vad som gäller paketering: det kan vara en konsolapplikation, en SharePoint-app, ett wsp-paket, en PowerShell-modul. Se följande länkar:

Testmiljö

För att testa behöver vi en site. Jag använder min http://dev/sites/004 som jag skapat just för det här. Av någon anledning gick det inte att använda Visual Studio 2015. Så jag har min Visual Studio 2013 på en virtuell maskin med SharePoint.

Målet

Provisionera jQuery och ett enkelt skript till min site collection.

Process

Installera Visual Studio Template

m2-001

Det här kommer leda till github. Ladda ner den därifrån:

m2-002

Godkänn och Installera

m2-003

Skapa ett nytt projekt. Solution ska vara Takana. Projektet ska vara Takana.Model

m2-004

Välj “Pocos only” och Takana som prefix och gruppnamn (i mitt litet labb kommer de här inte användas, men det går så snabbt att ställa in dem här):

m2-005

Man får en bra struktur över modellen, allt prefixat och enligt best practices.

m2-006

Jag kommer att använda de här modellerna sedan:

m2-007

Nästa steg är att skapa Provision-delen. Skapa ett nytt projekt i samma VS Solution. Kalla det Takana.Provision:

m2-008

Välj SharePoint Standard och SP2013 CSOM

m2-009

Efter det har vi en VS Solution med två projekt: Takana.Model och Takana.Provision. I Takana.Provision finns CSOMProgram.cs som startar provisioneringen:

m2-010

För att börja med, behöver man sätta Takana.Provision som Startup Project (blir fetstilt)

m2-011

Efter det måste ett tillfälligt problem lösas – referensen 16-foldern. Det här ett känt problem och kommer förmodligen lösas inom kort.

m2-012

Den snabbaste vägen till att ersätta referensen är att installera ett nuget-paket som heter SharePoint Online Client Side Object Model. Även om det är för SharePoint Online, funkar det alldeles utmärkt för OnPrem också.

m2-013

Efter det lägg till Takana.Model som referens

m2-014

Byt ut siteUrl, siteModel och rotWebModel:

m2-015

Det går fort att köra den här konsolapplikationen. Nu när jag går in på min site, ser jag att jQuery har provisionerats och ett litet skript också som skriver till konsolen.

m2-016

Sammanfattning

Det här en liten manual för hur man lätt kan komma igång och prova SPMeta2. SPMeta2 är ett kraftfullt ramverk som kan användas för provisionering och uppdatering av SharePoint-applikationer. Det kan finnas en tröskel i att börja använda det. Jag hoppas att med den här bloggposten jag kan göra fler nyfikna på att prova SPMeta2 och kodbaserad provisionering för att det är ett framtidssäkert sätt att arbeta med SharePoint.

Method “GetList” does not exist

I troubleshooted a piece of CSOM code in SharePoint 2013. I got the following error:

Method “GetList” does not exist

The reason was that the method GetList was not imlemented until March 2015 CU (15.0.4701.1001), and the SharePoint farm I had was SharePoint 2013 SP1 (15.0.4569.1000). So the solution is to install the Cumulative Update or use web.Lists.GetByTitle. GetByTitle has one aweful shortcoming: it doesn’t work in multilingual environments. So I have recommended to install the March 2015 CU.

Tillgänglighet i SharePoint

From 1 januari 2015 är bristande tillgänglighet inkluderad i svenska diskrimineringslagen. Detta krav på tillgängligt webbinnehåll ställer högre krav på SharePoint-baserade webbplatser i offentliga sektorn (och helst i alla webbplatser). Regler och riktlinjer för tillgänglighet på webben är definierade av W3C i ett dokument som heter: Web Content Accessibility Guidelines (WCAG) 2.0 vilket finns i en auktoriserad översättning på svenska: Riktlinjer för tillgängligt webbinnehåll (WCAG) 2.0. (Gjort av Funka)

Hur ska vi tänka om Tillgänglighet i SharePoint

Som vilket webbaserat system som helst bör man i SharePointlösningar tänka på tillgänglighet i alla faser av projektet. Liksom säkerhet och prestanda, finns Tillgänglighet med både i Design- och arkiktekturfasen, i utvecklingen, i lanseringen och utbildingen samt i förvaltningen av ett system. Det ska finnas med Governance-modellen.

SharePoint är såklart inte ett vanligt webbsystem, utan det är ett stort metasystem. Vi kan dela in det i tre lager för att kunna hantera problem som kan uppstå:

Tre lager av SharePoint som påverkar tillgänglighet.

”Sköldpaddor hela vägen ner”: Tre lager av SharePoint som påverkar tillgänglighet: Platform, Egna Lösningar och Använarinnehåll

  1. Platform (SharePoint-standarduppsättning). Microsoft har varit med och skrivit WCAG 2 och gör kontinuerliga förbättringar för tillgänglighet. Tillgänglighet i olika delar – olika features – i SharePoint varierar starkt. Ett exempel är att tabeller har minskat i sid-layouter. Ett annat exempel är att “Tags and Notes”-webparten (som har haft rentutav ogiltig html-markup) tas bort i SharePoint 2016 Preview.
  2. Egna lösningar/anpassningar (allt från tunga farmlösningar, masterpages, page layouts till enkla Content Editor Webparts). Vi, som konfigurerar och anpassar SharePoint, bör alltid tänka på tillgänglighet. Det ska vara självklart som arbete med prestanda och säkerhet. I varje projekt mäter vi och följer upp prestanda och säkerhet. På lika stort allvar måste vi ta tillgänglighet. Det är av fördel att ha riktiga tillgänglighetstester i en leverans.
  3. Användarinnehåll (redaktionellt material, newsfeed, listinnehåll, blogginlägg mm). Med hjälp av utbildning och intern marknadsföring bör man höja medvetenheten kring tillgänglighet. Ett av tydliga exemplen är att lägga till en beskrivande text på varje bild (som är ej dekoration). Vi, SharePointutvecklare, ska också skapa verktyg för att hjälpa redaktörer och vanliga användare att upptäcka tillgänglighetsbrister).

Onpremifying SharePoint apps

onpremify-001

We want to make an app available in SharePoint OnPrem, we want to onpremify it. Rethink SharePoint apps and provisioning SharePoint artifacts.

It has been a while since I updated my blog – Chuvash.eu. I had my vacation, I visited the sunny and green Chuvashia. Now I am back and I am looking forward to an awesome SharePoint Autumn. One of the first things I had to deal with in this SharePoint Autumn was Onpremifying of a SharePoint Online App. We have an app that has gained popularity and we want to make it available for SharePoint OnPrem. There is no such word Onpremify (yet?), I know, it is a Swenglish happy word making (onpremifiera), but I like the word “onpremify” a lot.

There is still uncertainty around the purpose of SharePoint apps. One app type, though, has been used a lot in our company: an app that provisions SharePoint Artifacts – that creates SharePoint Applications. What I mean by SharePoint Applications can be read in my blog post:

The successful app type creates SharePoint Applications – by provisioning needed SharePoint artifacts (Fields, Content Types, Lists, Page Layouts, Styles, Scripts, Web Parts, Pages…). Often it is a one time job: When the SharePoint application is provisioined, it is finished.

onpremify-002

When you’re about to onpremify such an app, you have three main choices:

  1. Install app in OnPrem. Requires the App Infrastructure in place and a separate build of the app (15.0.0.0 version)
  2. Make a parallel version of the app using a farm solution (not good at all)
  3. Invoke the provisioning code from a console app (I recommend this one)

The choice 1 might seem obvious, but not all companies have a functioning app infrastructure (a dedicated server for Provider Hosted apps, S2S Trust and Governance around it). The choice 2 splits your app into two variants and makes it hard to maintain.

On the other hand, the choice 3 might seem crazy, when you hear it for the first time. A Console App? But give it time, think about it. The idea comes from the awesome SharePoint Provisioning Library SPMeta2, where the Model (SharePoint Artifacts) and Executing are separated. Your model for Fields, Content Types, and Lists and so on, is an agnostic code based definition that can be used for SSOM and CSOM, for SharePoint 2013, SharePoint Online, SharePoint 2016 and SharePoint 2010. SPMeta2 eliminates the need for XML and wsp packages.

So my recommended approach for onpremifying SharePoint apps where the main goal is to provision SharePoint Applications is to move the provisioning code into a separate VS Project. The SharePoint App Project (mainly AppManifest.xml) remains the same, The App Web Project is made to a “stupid” interface that invokes the Provisioning Library. We also create a new interface – a Console App. You can replace the console app with a Windows Application, a Web Application, PowerShell Script, An admin page in Central Admin – whatever suits you. The Console app can be used not only in OnPrem, but also in SharePoint Online.

SPMeta2 vs. PnP vs. Own Framework

Every developer with Self-Respect uses a framework for provisioning SharePoint artifacts. It might be some own utilities or preferably public framework, because you don’t want to repeat yourself, especially in SharePoint. When SPMeta2 and PnP are available it is not smart to reinvent the wheel. I usually recommend to use one of them. I personally prefer SPMeta2 because… mainly because it is more complete and consistent. Read more about SPMeta2 vs. PnP comparison.

Resetting SharePoint Search Configuration Cache

Now it is the second time it happens that the search cannot return any results. This hickup is rare but it happens. To solve it I had to follow these steps:

  1. Stop the Timer Service
  2. Clear the configuration cache
    1. Find in \ProgramData\Microsoft\SharePoint\Config the folder where the file cache.ini exists
    2. Delete every file from this folder EXCEPT cache.ini
    3. Open cache.ini, delete the content and put ’1′ (without the quotes) in it and save the file
  3. Restart the Timer Service
  4. Index reset
  5. Full crawl

Source: ITIDea. The linked blog post saved my afternoon today. Thank you, Anita Boerboom.

Why Swedish matters

I Sverige är engelskan är väldigt stark. Speciellt i IT-branschen är vi vana att ha i princip allt på engelska, från kommentarer i koden till stora upphandlingar, rapporter och dokumentation. Trots det ser jag ett stort behov av att kunna prata om IT på svenska. Det gäller både lokala företag och globala företag. Det finns flera anledningar:

  • Företag i Sverige följer svenska lagar som är skrivna på svenska, för att leva upp till kraven ska man kunna formulera sig på svenska.
  • Modersmål eller det språk som man använder mest i vardagen (gäller mig bland annat) är den snabbaste vägen för kommunikation som ger en högre grad av nyansering. Att kunna nyansera krav och önskemål tidigt i projekt är guld värt (enligt många av mina korrespondenter). Man behöver spendera mindre tid på att formulera och tolka krav.
  • En mer ideologisk anledning (men en viktig sådan) är att vi som bor i Sverige har skyldighet att utveckla och hålla svenskan levande, inte minst inom IT-sektorn.

Svenska är en stor möjlighet för att verkligen ge mervärde till våra kunder, möta dem på hemmaplan, prata ett gemensamt språk.

Startpunkten till den här diskussionen har varit en ny webinar som jag planerar hålla den 14 april kl 10. Webinarens titel är SharePoint i molnet.Det finns ganska mycket information om SharePoint Online och Office 365 på engelska. Det är dock ganska sparsamt med information på svenska.

https://www.eventbrite.com/e/sharepoint-i-molnet-tickets-15976529229

Det här är det som väntar dig som vill delta i webinaren:

Intresset för SharePoint Online och Office 365 växer allt mer. Vad behöver man tänka på när man ska använda SharePoint i molnet, vilka är fördelarna och vilka är nackdelarna.

I den här webinaren pratar vi även om skillnaderna mellan SharePoint Online och SharePoint 2013. Vi bjuder in till en webinar med öppen diskussion för era frågor.

Den här webinaren är för er som:

– Vill veta mer om SharePoint Online.

– Vill lyssna och diskutera det på svenska.

– Vill höra om andras erfarenheter och tankar kring det.

Detaljer om hur man deltar i webinaren kommer lite senare.

Publishing Visio drawings as SVG

svg-004

In my post yesterday I showed how to publish Visio files as html image maps. That was one of the alternatives. Today I’ll present how to use SVG to achieve the same goal: publish Visio diagrams in SharePoint without having the Enterprise license. There are some alternatives:

  1. Show Visio diagrams as pdf files on SharePoint Pages
  2. Embed Visio diagrams as html image maps – Read more in my previous blog post
  3. Embed Visio diagrams as svg pictures – This blog post.
  4. Link to Visio files that are opened using Visio Web Viewer in a new browser tab.

SVG

SVG stands for scalable vector graphic, it is a xml-based format for defining images. It is supported in all modern browsers. Because SVG can be part of a page markup, it can be easily embedded into SharePoint.

Visio

In Visio you can save a drawing as SVG. Thanks to my smart colleague: Dan Saeden. So the process of exporting and embedding a drawing is almost the same as for an image map. An improvement is that you don’t have to update the html markup and you don’t need to upload or base64-encode any pictures. It’s all in the markup (DOM). See some screenshots below.

Advantages and Disanvantages

Compared to image maps and other methods, we get following advantages:

  1. It is scalable (not pixelish) – you can show it in a small screen, and a big screen.
  2. Only markup is needed (xml), no need for uploading images
  3. No additional bandwidth is required for downloading images to the browser
  4. No need for updating html structure, easier to explain how to do it.

There are also some disanvantages:

  1. Complex SVG files increase the DOM complexity and it may affect the performance in browser
  2. No support for older browsers: In IE8 it won’t work

svg-000

How to

Use your drawing of choice:

svg-001

Save it as an SVG file:

svg-002

Add a Script Editor Web Part to a page and paste the content of the svg file (open it in a text editor):

svg-003

That’s it:

svg-005

Summary

Visio files can be exported to many different formats. SVG is a great modern html standard for graphics that acts as a part of the DOM. It still requires a manual process of exporting and putting it on a SharePoint page, but it is a good way to make it modern, fast and even responsive (with some additional css). Editors don’t need to adjust the markup, only copy it.

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

| Blockchain | Serverless Architecture | Microservices Architecture | DevOps | AWS Lambda | Teraform |

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis