Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Archive for August, 2014

Create a Composed Look

Posted by Paul on August 30, 2014

In this article we can explore about Composed Looks which is a new feature in SharePoint 2013.

Composed Look

A composed look is similar to theme in such a way that it contains ready-made Look and Feel elements including:

· Background Image

· Font Palette

· Color Palette

· Master Page

· CSS

Themes

In SharePoint 2013 there is another Themes link which is actually a library for storing color palettes and font palettes. The meaning of theme is different comparing SharePoint 2013 and older versions.

Creating a Composed Look

For creating a new composed look, please follow the steps below.

Open Site Settings page.

clip_image001

Click on the Composed looks link. You will get the following page.

clip_image003

Click on the new item link. You will get the following page.

clip_image005

Here you can enter the following:

1. Title of composed look

2. Name of composed look

3. Master Page URL which can be copied from the Master Pages link

4. Theme URL which is actually the color palette URL and can be copied from Themes link

5. Image URL for the logo which can be copied from a picture library

6. Font URL which can be copied from the Themes link.

Once a composed look is created, you can see the same in Look and Feel link.

Summary

In this article we have explored Composed Look creation.

Advertisements

Posted in SharePoint, SharePoint 2013 | Tagged: , | Leave a Comment »

Color Palette Tool

Posted by Paul on August 27, 2014

In this article we can explore more about the Color Palette Tool.

Color Palette Tool

Color Palette Tool provides a graphical user interface for editing colors in a color palette file.

image

Installation

The tool can be downloaded from:

http://www.microsoft.com/en-us/download/confirmation.aspx?id=38182

After installation you can open it from start menu.

image

Color Slots & Buckets

There are 89 color slots for a SharePoint Color palette. In the default view colors are grouped as Buckets. Bucket is a grouping base on same color.

Clicking on the color button we can get the color dialog.

image

Changing View

There are 3 views available:

1. Bucket View

2. UI Groups View

3. UI Type View

image

Color Preview Slots

Towards the right bottom Color Preview Slots are available. The colors selected here will be displayed in SharePoint color palette drop down list.

image

Layout

We can choose a layout from the preview pane.

image

Recolor

We can quickly create a new theme using the recolor option. Click on the color picker icon.

image

Choose the color from color picker and click the Recolor button. You will get a new theme based on the color selected.

image

Saving

Once the new color palette is created we can save the changes into a .spcolor file using File > Save menu. Following is the content of the .spcolor file.

image

image

For installation of color palette see references section.

References

http://www.microsoft.com/en-us/download/details.aspx?id=38182

http://www.jeanpaulva.com/index.php/2014/08/18/color-palette/

Summary

In this article we have explored the Color Palette Tool.

Posted in SharePoint, SharePoint 2013 | Tagged: , | Leave a Comment »

Security Trimmed Control

Posted by Paul on August 21, 2014

In this article we can go through Security Trimmed Control without using any custom code.

Purpose

While building SharePoint user interface controls, we need to security trim some controls based on the current user’s permission.

A user can be given permission level like:

1. Full Control

2. Contribute

3. Read

Etc.

Each Permission Level can map to different Permissions like:

1. Manage Web

2. Add List Items

3. View Pages

Etc.

Security Trimmed Control

The assembly Microsoft.SharePoint.WebControls contains control named SPSecurityTrimmedControl which performs the security trimming of the child controls inside it. Just include our control inside this control and it will be displayed or hidden based on the permission specified.

Code

Following is the code of Security Trimmed Control. You can add this to a web part design code.

<%@ Register TagPrefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControl1″ runat=”server”

AuthenticationRestrictions=”AuthenticatedUsersOnly” Permissions=”ManageWeb” PermissionContext=”CurrentSite”>

<INCLUDE OUR CONTROL HERE>

</SharePoint:SPSecurityTrimmedControl>

3 Buttons

We are planning to show 3 buttons like:

clip_image002

Following are the permission requirement for each buttons.

· Manage Web

· Add List Items

· View Pages

Following is the code for the same.

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControl1″ runat=”server”

AuthenticationRestrictions=”AuthenticatedUsersOnly” Permissions=”ManageWeb” PermissionContext=”CurrentSite”>

<button runat=”server” id=”b1″>Manage Web</button>

</SharePoint:SPSecurityTrimmedControl>

<br />

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControl2″ runat=”server”

AuthenticationRestrictions=”AuthenticatedUsersOnly” Permissions=”AddListItems” PermissionContext=”CurrentSite”>

<button runat=”server” id=”b2″>Add List Items</button>

</SharePoint:SPSecurityTrimmedControl>

<br />

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControl3″ runat=”server”

AuthenticationRestrictions=”AuthenticatedUsersOnly” Permissions=”ViewPages” PermissionContext=”CurrentSite”>

<button runat=”server” id=”b3″>View Pages</button>

</SharePoint:SPSecurityTrimmedControl>

Infrastructure

You can create a Farm Solution and add a Visual Web Part into it. Build & Deploy the project and add the web part to a page. You need 2 user accounts to test this. The first user account be the System Account and the second user as the test user. I recommend using 2 different browsers – one for changing the permission as system user & other for viewing the page as test user.

Full Control

Following is the page output when the test user is given Full Control permission level.

clip_image004

He can see all the 3 buttons.

clip_image006

Contribute

Following is the page output when the test user is given Contribute permission level.

clip_image008

He can see only the second 2 buttons.

clip_image010

Read

Following is the page output when the test user is given Read permission level.

clip_image012

He can see only the third button.

clip_image014

More Understanding

Please note the following:

1. We are specifying authentication restriction as AuthenticatedUsersOnly

2. The permission context is specified as CurrentSite

clip_image016

Permission Context

Following are the Permission Context values:

· Current Folder

· Current Item

· Current List

· Current Site

· Root Site

You can specify this in the XML:

clip_image018

clip_image020

Using Security Trimmed Control can save lot of code require otherwise.

References

http://msdn.microsoft.com/en-us/library/office/jj822366(v=office.15).aspx

Summary

In this article we have explored the Security Trimming Control in SharePoint 2013. I hope this will be helpful in real world scenarios.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | 2 Comments »

Delete Comments by Note Board Web Part

Posted by Paul on August 20, 2014

In this article we can explore a problem raised by using Note Board web part and the solution for it.

Note Board Web Part

Note Board web part can be associated with any page. The web part allows comments to be typed by the user.

The Problem

Problem arises when a deleted page is recreated with same name; the old comments also got restored.

For generating the problem:

1. Create a wiki page

2. Add some comments against it

3. Delete the wiki page

4. Recreate new wiki page with same name

5. You can see the comments appearing back

clip_image002

Solution

The internal class name for Note Board web part is SocialCommentWebPart. SharePoint store the comment information in Social database along with the page URL.

We need to delete the comment from the database. For this we have to use the SocialCommentManager class. Another challenge is there is no public method to delete the comments. We have to use reflection to call the private method.

Code

Following is the code which performs the same. You need to input the URL and a reference site object.

public static bool DeleteComments(SPSite site, string url)

{

bool result = true;

SPServiceContext serviceContext = SPServiceContext.GetContext(site);

SocialCommentManager manager = new SocialCommentManager(serviceContext);

SocialComment[] comments = manager.GetComments(new Uri(url), 1000);

foreach (SocialComment sc in comments)

{

try

{

PropertyInfo propertyInfo = typeof(SocialComment).GetProperty(“CommentID”, BindingFlags.NonPublic | BindingFlags.Instance);

object o = propertyInfo.GetValue(sc, null);

if (o != null)

{

Type t = manager.GetType();

MethodInfo mi = typeof(SocialCommentManager).GetMethod(“DeleteComment”, BindingFlags.NonPublic | BindingFlags.Instance,

null,

new Type[] { typeof(long) },

null);

long id = Convert.ToInt64(o.ToString());

mi.Invoke(manager, new object[] { id });

}

}

catch

{

result = false;

}

}

return result;

}

References

You need to refer the following assemblies:

clip_image003

Running the Code

After running the code I can see the comments are deleted for the given URL.

clip_image005

clip_image007

You can connect the deletion code to a custom event handler for your list/library.

References

http://bit.ly/1rVoo1Z

Summary

In this article we have explored how to delete the comments of a Note Board web part. Please see the console application code attached.

Posted in Uncategorized | Leave a Comment »

Color Palette

Posted by Paul on August 18, 2014

In this article we can explore how to create a color palette & deploy it.

Color Palette

A Color Palette is a combination of colors used in a SharePoint site. Each Master page contains multiple elements with color-names. A color palette contains color values for these pre-defined names.

A Color Palette has the extension .spcolor.

Following is the content of a sample .spcolor file.

image

Location of Color Palette File

The color palette file resides in the root site collection themes folder. You can access the location from Site Actions > Site Settings > Themes page.

image

Following is the Themes page.

image

Creating New Palette

You can open the themes gallery > 15 hive folder > download an existing .spcolor file. Later modify the color values according to your need.

Deploying New Palette

You can open the themes gallery > 15 hive folder > choose new document. In the appearing dialog choose the new spcolor file and upload.

image

Once uploaded, you can see the new palette in look and feel page.

image

Editing files

We can open the .spcolor file in notepad & edit the color hex values. Alternatively, there is a very good tool named Color Palette Tool which provides a graphical user interface in editing colors.

image

The tool can be downloaded from:

http://www.microsoft.com/en-us/download/confirmation.aspx?id=38182

Please find my other article on using the same.

image

Please note that the themes folder also contains font files.

References

http://msdn.microsoft.com/en-us/library/office/jj945889(v=office.15).aspx

Summary

In this article we have explored color palette and deployment.

Posted in SharePoint, SharePoint 2013 | Tagged: , | Leave a Comment »

Community Site Portal Template

Posted by Paul on August 15, 2014

In this article I would like to explore the Community Site Portal template of SharePoint 2013.

What is Community Site Portal?

Community Site Portal is a template that lists all community sites underneath it.

What are the steps to create Community Site Portal?

Please follow the steps below:

1. Create a site collection using Central Administration

2. Choose the Community Site Portal template

3. Create new communities under the site collection

Steps

Following are the visual steps:

Step 1: Open Central Administration

clip_image001

Step 2: Create Site Collection

Choose the Create site collections link & select the template as shown below.

clip_image003

Fill the remaining properties & click the OK button. You will get the site collection created.

clip_image005

We can access community settings from the Site Actions > Site Settings > Community Administration link.

clip_image006

Step 4: Activate Community feature

From the newly created site collection, choose Site Actions > Site Settings > Manage site features.

clip_image008

Activate the Community Site Feature as shown above.

Prior to this you might need to activate the following site collection features.

clip_image010

Step 5: Create sub sites

Now we are ready to create sub sites underneath it choosing the Collaboration > Community Site template.

clip_image012

Create few sub sites like this under the site collection.

clip_image014

The Community Portal template is only available for site collections. So we need to use Central Administration or PowerShell to access the template.

References

http://bit.ly/1mPhFDi

Summary

In this article we have explored Community Site Portal template.

Posted in SharePoint, SharePoint 2013 | Tagged: , | Leave a Comment »

Error :: Exception calling “CreateGroup” with “1” argument(s): “The current user has insufficient permissions to perform this operation.”

Posted by Paul on August 10, 2014

I was working on Terms creation & faced the following error:

Following error occurred –> Exception calling “CreateGroup” with “1” argument(s): “The current user has insufficient permissions to perform this operation.”

I tried the following options & did not worked.

  • Run as Administrator
  • Added current user to the Central Admin > Managed Metadata > Permissions

Solution

Open Site Settings > Term Store Management Tool

image

In the appearing page > Term Store Administrators box enter the current user.

image

Save changes & Retry again.  You should not be seeing the error again.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

Error: The content database in this cluster are full. You cannot add more Web sites until you change the content database Web site capacity settings or add more content databases.

Posted by Paul on August 8, 2014

While creating a new site collection, I receive the following error.

Error: The content database <dbname> in this cluster are full. You cannot add more Web sites until you change the content database Web site capacity settings or add more content databases.

image

Solution

Open Central Administration > Manage content databases

image

You will get the following page.  Identify your database name from the error & click on it.

image

In the appearing page increases the count of sites to 2000 & 5000 respectively.

image

The first count is Warning value & second for Max value.

Save Changes & Try creating the site collection again.  The error should disappear.

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

SharePoint 2013 Branding

Posted by Paul on August 5, 2014

In this article series I will take you through the Branding essentials of SharePoint 2013.

What is SharePoint Branding?

SharePoint Branding is the process of changing look and feel of SharePoint user interface using custom master pages, style sheets, images, JavaScript, JQuery etc.

image

Few of the branded sites are shown below.

image

What are the advantages of Branding?

A good branding leads to:

1. Better content presentation

2. Better navigation

3. Better look and feel

4. More browser support

5. Enable responsive web design

6. Increased user adoption

7. Hide SharePoint look and feel

What are the Skills needed for Branding?

You need to know HTML, CSS & Basic Scripting skills. Additional to that, SharePoint Branding knowledge is an essential skill to integrate the custom branding artifacts.

SharePoint Branding knowledge includes:

· Master Page location

· Master Page elements like Site Settings, Quick Launch etc.

· Design Manager expertize

· Composed looks

Do I need to be a Graphics Designer?

Not Needed. You can be a SharePoint Branding Expert who will work with another Graphics/Web Designer for collecting the HTML, CSS, Image files & integrating to SharePoint.

What are the new features of SharePoint 2013 supporting Branding?

SharePoint 2013 introduced lot of good features which makes branding a lot easier compared with the old versions, naming a few are:

1. Design Manager which helps in converting an HTML file to SharePoint Master page

2. Device Channels for enabling custom master pages based on user devices

3. Composed Looks for putting together branding elements like master pages, color palettes etc.

4. Look and Feel to apply a composed look, change color, background image etc.

You can access these pages from Site Actions > Site Settings menu.

image

image

Publishing feature needs to be activated for getting the Design Manager feature.

What are the Branding Elements in SharePoint 2013?

Following are the branding elements in SharePoint 2013:

1. Master Pages

2. Preview Files

3. CSS Files

4. Color Palettes

5. Font Palettes

6. Images

image

What is Theme in SharePoint 2013?

The term Theme is defined to group the color & font palettes.

You can access the same from Site Actions > Site Settings > Theme page as shown below.

image

References

http://msdn.microsoft.com/en-us/library/office/jj733518(v=office.15).aspx

Summary

In this article we have explored an overview about SharePoint 2013 branding.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

JS Link for Web Parts

Posted by Paul on August 1, 2014

SharePoint 2013 has a new CSR (Client Side Rendering) support through the JS Link property for web parts.

What is JS Link?

JS Link is a property available for web parts.  We can specify a client side script file here.  The scrip will be executed once the page gets loaded; on the client side.

This feature enables us to quickly associate JavaScript & JQuery files rather than using the Content Editor web part.

How to set the JS file?

Open a list or library and choose Edit Page > Edit Web Part option.

image

Open the Miscellaneous tab and you will see the JS Link.

image

You can set your client side script file for this property.

image

~sitecollection

We can use the pre-defined ~sitecollection for accessing the site collection path.

References

http://msdn.microsoft.com/en-us/library/office/jj193034(v=office.15).aspx

Summary

In this post we have explored the JS Link property and its usage.  I hope this will help you take advantage of the SharePoint 2013 features.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »