Posts

Showing posts with the label 2013

Change the language settings on every mysite

Running a SharePoint Site with different languages? No problem! But making sure every user has the correct language settings? Maybe a problem. So why don't using Powershell? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [Microsoft.SharePoint.SPSecurity] ::RunWithElevatedPrivileges({ # Enables SELECTED installed languages for each subsite in a site collection $webAppURL = "https://mysiteurl/" $webApp = Get-SPWebApplication $webAppURL foreach ( $spSite in $webApp .Sites){ $spWeb = $spSite .RootWeb $spWeb .IsMultilingual = $true $WebRegionSettings = New-Object Microsoft.SharePoint.SPRegionalSettings( $spWeb ); foreach ( $language in $WebRegionSettings .InstalledLanguages) { If ( $language .DisplayName -eq "English" -or $language .DisplayName -eq "German" ) { # Add the displayname of any langauge you have installed: -or $language.DisplayName -eq "Norwegian" -or $la...

Changing the author field in SharePoint

An action nobody should do, but in some cases necessary: changing the author of an item. What do you need? a farm account PoweShell

Set SharePoint's PeoplePicker value with jQuery

PeoplePicker and default values - not so easy in SharePoint. So if you want a default value for a field you need to set it by your own, but how?

SharePoint's Choice Fields: how to arrange checkboxes or radiobutto in one row

Image
Of course there are multiple reasons to use checkboxes or radiobuttons - even in SharePoint. But the most common problem: if you have more than three choices your form is blowing up. The solution is to arrange them in a row. To do so we need to take a deeper look.

Canceled events in SharePoint calendar

Email-enabled calendars are great. Just add the calender into the recipients and your event appears in the SharePoint calendar. But what if you cancel the event? The event will be deleted in Outlook, but not in SharePoint..

Restart the SharePoint OWSTIMER

There are a lot reasons to restart the Timer Job in SharePoint. You can do it by going to Services and stop the owstimer service. Is this the only way? Are there more even better ways? Well, there are some other ways, but there is no best practice. 

SharePoint REST - get more than 100 list items

Since SharePoint 2013 you can use REST calls to get or set data. But if you firing a call against a list with 101 items you will get only 100. The cause is based at the REST interface. To reduce server overload the result is limited - it is called server paging. That is pretty smart, but what if you need all results? There are two ways of solving this problem. The first and easy one is to set the $top flag. So you add ?$top=101 to your REST call and you will get all 101 items. This works fine until you have 102 items.

Refresh the User Information List in SharePoint

If you are going into the User Information List, you will sometimes see it is not up to date. There are two jobs (User Profile to SharePoint Quick Sync and User Profile to SharePoint Full Sync). The quick sync will only add new member into your list and somehow it does not work sometimes. So you need to trigger the full sync. The question is how.. there is no point in the UI to do so and not even PowerShell is able to start it. The good old stsadm will rescue us. There are two commands you need to execute in your SharePoint Managing Shell (as administrator).

SharePoint get field by GUID with PowerShell

Once I was looking for a problem in SharePoint, I've spent some time digging the ULS Logs. There was an error with the message " Failed caching field with id '{GUID}' ". The first problem I had was the question: which field? So I decided to build a script that returns the name of the field. After I knew the name, I wanted to know where the field is used, so I extended the script. Now it returns the Lists and Content Types where the field is in use.

Wait dialog in SharePoint 2013 with JavaScript

Some actions in SharePoint (e.g. executing querys) can take a while. You want the user to not do any action or even change the data while your process is running. So you need the wait dialog that SharePoint is displaying some time. Calling the dialog is pretty easy. All you need is a line of code.

ClientSideRendering basics 2

Image
In my last post  I extended the view of a list. The goal was to add the unit of measurement next to a numeric value. Now I want to extend it by adding the unit into the forms (new, edit and display) of this list. This is how the form usually looks like: At first we need to write the code.

ClientSideRendering basics

Image
Lists in SharePoint 2013 are very minimal and nice looking. You can have multiple use cases for a list. For example a list of cars. I made a very simple list of cars with three columns: We can see the title the power and the manufacturer, but what is the unit of measurement for the power? To answer this question we should build in the unit.

SharePoint Views [Me]-Filter in Schema.xml

Image
Everybody knows the [Me]-Filter in views. It is a nice way to help me seeing my items. This filter is set in SharePoint pretty fast.. you just need to modify you view, scroll down to the filter region and select a person field and show it if its equals the value "[Me]". It looks like this:

Get the mail address from a FieldUserValue Client Side vs Server Side

In SharePoint are two ways to code by using an object model. The one way is the Client-Side Object Modell (CSOM) and the other side is the Server-Side Object Model (SSOM). At the first look they both look the same the only difference is how the objects are looking for example the is the 'Site'-object (client side) is called 'SPSite' on server side. A good way to demonstrate the difference is to get the mailaddress of a userfield. That sounds easy, but needs more lines that I thought at first. So let's say you got a SharePoint 2013 and want to read the mailaddress on client side. That would look like this: 1 2 3 4 5 6 7 8 9 // get the userfield of the item e.q. Author FieldUserValue Author = (FieldUserValue)currentItem[ "Author" ]; // ask the web to find a user with the id in the field (only works if the user visited the site) var user = web.SiteUsers.GetById(Author.LookupId); // load the data with the context context.Load(user); context.ExecuteQue...

SharePoint 2013 apps - communicate with host SharePoint without using SP.RequestExecutor

In a previous post  I wrote an app to read and write data from the Host-SharePoint. To do this I made use of the SP.RequestExecutor. This class is used to get the permissions for reading and writing data into the Host-SharePoint. But there is a way to skip the authentification and using the URL directly. This makes your code much more beautiful and easy to read. All you need to do is to call a function (_spPageContextInfo.siteAbsoluteUrl). That function returns an URL and makes it possible to communicate with the SharePoint per JSOM and REST.  I also tried to call the URL with the function and make a context with another URL and this does not work. Even the Host-URL does not work. Another disgusting point is that the URL, which is returned by the function, is that it not contains the URL of the app and not of the host. It is a 'hybrid' that begins like the app URL, but ends earlier. 1 2 3 4 var url = _spPageContextInfo.siteAbsoluteUrl; context = new SP.ClientContext(u...

Open Edit View of SharePoint Pages without the "Edit Page" button

In some cases the "Edit Page" button is not visible too make sure no one makes some unallowed changes. This is a nice security hack, but what if you need to edit the page? There is an easy way to open the page in edit mode and that is the URL. Add one of the following extensions to your URL, right after the '.aspx'. To change the public view of the page add this: ?PageView=Shared&ToolPaneView=2 example: http://sp/Pages/default.aspx ?PageView=Shared&ToolPaneView=2 To change a personal view of the page add this (only if it is enabled): ?PageView=Personal&ToolPaneView=2 example: http://sp/Pages/default.aspx ?PageView=Personal&ToolPaneView=2

SharePoint 2013 app - get data from the SharePoint

Image
For safety reasons apps are seperated from the SharePoint where they are installed on. Apps are installed on other domains and that is how the seperation works. Apps can't contact the SharePoint, because Cross-Site-Scriptingis blocking it. But there is still a way to get data from the SharePoint and with this way comes a permission concept into the app world. Permissions There is a library, called the Cross Domain Library, that allows to communicate with a SharePoint from app site. This library is aviable on every SharePoint 2013 and is easy to call. But wait.. if it is so easy to call a library that can get SharePoint data it is not saver than before. This library contains more than communication.. it authentificates the app against the SharePoint and asks for permissions. This happens right after the installation of the app. The installing user will be asked to grand permissions for the app. But how does the app know what permissions are needed? Asking for permissions is you...

Basics for SharePoint 2013 app development

Image
The biggest innovation in SharePoint 2013 is the app-architecture. With this innovation it is possible to install applications (apps) on a SharePoint. This applications can be developed by yourself or you can buy them in the SharePoint Store. They are totally detached of the SharePoint and got their own area. They can contain own lists, have own sites with custom code and they have their own interfaces. But it is possible to communicate with the SharePoint. My first app To develop an app you need Visual Studio 2012 or above and a development SharePoint. To begin start Visual Studio as administrator and click 'New project...'. A mask opens where you can choose a template. Go to 'Templates' → 'Visual C#' → 'Office/SharePoint' → 'Apps' and select 'App for SharePoint'.

How to set up a SharePoint 2013 app development environment (without DNS)

Image
With SharePoint 2013 Microsoft integrated the app contept into the SharePoint world. This gives us new opportunities, but also sets new requirements. SharePoint apps got their own enviroment where they will be installed and run. With this step Microsoft made sure the SharePoint experience will not be affected negativ by bad running apps or apps that want to steal data. But this isolation requires, that apps got their new oen DNS entry. The app do not have the same URL as the SharePoint. An app URL looks like this: <prefix>-<GUID of the app (will be generated automatic)>.<appdomain> (example: http://app-005f804530bdb6.app.development/). To create and manage a new DNS entry is way to much work for a development enviroment and that is the reason why there is a way to do it without DNS.

fix the 'Sideloading of apps is not enabled on this site' problem with PowerShell

In case you are developing an app for SharePoint 2013 and you are not developing on the server you can get the error 'Sideloading of apps is not enabled on this site'. When that happens you do not have the sideload developing feature activated. It is a hidden feature and allows you to develop apps from client devices. All you need to do is to enter the following line into PowerShell on the server. Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url <yourSharePointURL>