Saturday, May 24, 2014

ShareCamp 2014 - My first visit

This year I was finally able to get time off to go to ShareCamp near Munich and meet people from the community and listen to a lot of new features, ideas and concepts. I really like the style of community driven events like this one, because it is a lot more open  to different kind of ideas or approaches and stuff you can show off.

I think that this concept is one of the best ones I've seen in a long time. Of course I took a couple of pictures and I gonna post them at the end of this text.  I won't go into too much technical detail, because I want to give you a feeling about how this got done during this weekend.

Let's face it: most of the time, people are just talking and talking and won't show you a lot of stuff. But at ShareCamp I saw a lot of actual work, which was great. Of course you won't be able to get to every lecture (it's sad) which forces you to pick the most interessting for you. In my case I was listening to VMs (SharePoint) in Azure (by Patrick Heyde), Windows Phone 8.1, ShareCoffee (created by Thorsten Hans), SharePoint App Development (AngularJS & REST API) on Saturday. It was more development stuff than I had planned, but what the hell: Sometimes you just have to run with it.

It was a lot of fun to listen to the people who were talking, even when things got a bit bumpy. The picture I took during those lecture aren't that good, but I think it's enough for a little impression.

I liked it a lot and hopefully I will get some of the PowerPoint or codes from the lectures.

Thursday, May 15, 2014

Visual Studio 2010: Event Receiver Name Change

I change the name of an event receiver in my solution, just because I think "EventReceiver1" isn't such a good name. I was sure this thing would work, so I tried to deploy it on my SharePoint 2010 Farm and was stunt when I saw that it wasn't able to activate it.

So what did I do wrong? Simple!
After you change the name of the event receiver make sure you open the Elements.xml and change the name in the <class> attribute accordingly.

I'm still wondering, why something like this isn't done automatically.

Wednesday, May 14, 2014

SharePoint 2010: How to activate Target Audience

I had a bit of trouble, like most days for the last two weeks, to get my coding done. Again, it's because I usually don't code as much as I do at the moment. I need to create a field "Target Audience" and fill it with the correct value. Funny thing so: I shouldn't just create this field as a new Site column or something like that. I need to activate audience targeting first. But: How do I code an activation script of some kind in C#?
You will find two links below with an explanation, but I wanted to post the code anyway so it might be easier to find.

// Activate audience targeting
try
{

// Get the list where you want to activate audience targeting
SPList myList = myWeb.Lists["LIST"];
// leave this as it is, only change the "Required" attribute
XmlElement fieldElement = new XmlDocument().CreateElement("Field");
fieldElement.SetAttribute("ID", "61cbb965-1e04-4273-b658-eedaa662f48d");
fieldElement.SetAttribute("Type", "TargetTo");
fieldElement.SetAttribute("Name", "TargetTo");
fieldElement.SetAttribute("DisplayName", "Target Audiences");
fieldElement.SetAttribute("Required", "FALSE");
myList.Fields.AddFieldAsXml(fieldElement.OuterXml);
myList.Update();

}

catch
{
}
And here are some more links with information on this topic:
http://www.c-sharpcorner.com/uploadfile/anavijai/enable-audience-targeting-for-sharepoint-list-using-powershell/
http://blogs.msdn.com/b/syedi/archive/2008/09/12/enabling-the-audience-targeting-through-object-model-moss-sharepoint-2007.aspx

Monday, May 12, 2014

SharePoint 2010: Roll-out files with a solution in C#

Usually I don't tend to code as much as I do right now, which of course means that I'm a bit rusty. So naturally this one freaked me out. How do I deploy files, like JavaScript, CSS, with a solution. Of course I could just copy all the files in afterwards, but I wanted to have a slick solution with just a click of a button.

I ended up using Modules. Click on your project, add a new item and search for "Module".
Now place the files you need in this Module and open the Elements.xml. It will be automatically filled with the files from the Module. But maybe you want to store them in a differen library.
So heres the content of the Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="NameOfModule" Url="TargetLibrary">
<File Path="PathWithinTheModule" Url="TargetFolderWithinTheLibrary" Type="GhostableInLibrary" />
</Module>
</Elements>

I will come back to this post and add a couple of comments, but feel free to comment if you need help with this. Also I will add a couple of screenshots on how to add a module.

SharePoint 2010: Hide Recycle Bin & All Site Content

1. Create a "Content Webpart" somewhere on your SharePoint Page.
2. This is the code to hide it:
<style type="text/css">
.s4-specialNavLinkList
{
display:none;
}
</style>

SharePoint 2010 / 2013: Create a document library with C#

This is how you create a document library with C# in a farm solution:

Guid myListID;
myListID = myWeb.Lists.Add("LibraryName", "Library Description", SPListTemplateType.DocumentLibrary);
myWeb.Update();
It's pretty easy and mostly self explanatory. I placed this in an event receiver so that I can create document libraries on feature activation. Works pretty good.

Wednesday, May 7, 2014

SharePoint 2010: Create a custom view for a survey

I had a funny little problem: Show specific results from a survey without using jQuery, PowerShell or Excel. Sometimes I wonder how people come up with those problems, but they do. So how did I fix this?

First thought: Of course! A custom view. Yeah, sounds about right, with a couple of filter options and what not. BUT: There is now way of creating a view. The buttons and links are missing. Thanks, exactly what I needed.

To get around this, you just have to use a little bit of magic:
1) Go to the settings page of your survey and copy the link from the addressbar:
http://DOMAIN/SITE/_layouts/survedit.aspx?List=LISTID
2) Now we just use this link und survedit into viewtype: http://DOMAIN/SITE/_layouts/viewtype.aspx?List=LISTID
3) Create your view


Well, that was an easy problem for once.