CategoryUncategorized

The power of Quick Links web part

One of the most used SharePoint web parts is the quick links web part, but I feel like people really underestimate its capabilities when it comes to how you can change its look in your SharePoint pages. For me, it’s one of those web parts that I call as Swiss-knife web parts.

The power of the Quick Links web part is in its different layout combined with how it adapts based on the section where it exists as well as the ability to include gif images which makes them attractive – when using the right gif image that is!

Quick Links web part has 6 layout options:

When adding a link, you can choose to include an icon or an image for that link. In the examples in this article I will be using a web part with 4 links for 4 different animals, each one with its own image.

Compact Layout

We can see the Compact Layout when used in a vertical section like this:

However when it’s used in a two columns section layout:

If you provide it the whole width, it will look like this:

Filmstrip Layout

Vertical Section

Two columns section layout:

One-third right section layout (added to the left):

If you provide it with the full width, it will show all four images and hide the arrows. If you add one more link, it will start showing the arrows again and allow you to scroll.

Grid Layout:

Grid layout in a vertical section:

Two columns section layout:

One-third right section layout (added to the left):

List Layout:

Vertical section: With no description – No Icons:

Two columns section layout:

Two columns section layout space with no icons:

Tiles Layout:

Fill space property

 It would look like this in a vertical section:

And two columns section layout:

Button Layout:

With descriptions – Fill color – No icon:

Two columns section layout, no outline, icon on top:

One-third right section layout (added to the right) :

As we see, the same web part with the same layout would look different depending on the section layout where it’s placed. How it looks in a two columns section would look different from one-third section.

I have a created a very short video to show different options that might give you an idea of the possible things to do with the quick links web part:

See you in Burlington, MA! #CollabDays

I will be speaking in CollabDays New England on October 9th for a talk about Microsoft Teams Development including Tabs, Messaging Extensions, Bots Webhooks and all the fun stuff!

The event is going to be in person, first one after the pandemic! See you there!

Creating Dynamic List Menu For SharePoint Foundation 2013 Navigation

Hello Everyone, today’s article is going to have an intensive information about how to style the navigation menu for SharePoint Foundation 2013, in this case, we’ll have some common requirements, and we’ll go through how to achieve them to deliver a nice looking menu for the top navigation.

Problem:

The requirement that we have this time, is to create a menu which will include sub-items (dynamic items) that will appear when we hover over the static menu item.

We need all static menu items to have the following characteristics:

1- To be in uppercase format, meaning all letters in the sentence should be capitalized.

2- To have the white color, and a custom color: #f0b530 in case of anchor hover (Note that some of the static items maybe used only as containers for dynamic list items, and don’t act as hyperlinks).

The characteristics for the dynamic list that appears when we hover over a static item that contains sub-items:

1- To have the width of the maximum li that will appear inside the list, if you have a list item that will be 400px long, the ul should stretch to fit that size.

The characteristics for the dynamic items inside the list:

1- To have the “>” before each item

2- To have only the first letter in the sentence as capital letter, only the first letter in the sentence.. remember that!

3- On hover, to have a custom color, same one mentioned earlier: #f0b530

These are the requirements, so let’s get to the solution, shall we?!

 

Solution:

 

First things first, for my example, I use the following css to set the background color for my menu:

.ms-core-listMenu-horizontalBox {

background-color: rgb(163,160,143);

text-transform: uppercase;

}

Now we will need to style the static menu items that act as a container for my ul, to give them a white bold text, use the following css:

li.static span.dynamic-childrenspan {

color: white;

font-weight: bold;

}

As you see in the image below, the background color gave us a nearly grey background, and all letters in the static items are uppercase as required, note also that they are bold and white colored which what the second css snippet does.

nav1

Now, what if we hover over the “RESSOURCES HUMAINES” item, ul should be displayed with all items inside, and we should have the ul width to equal the longest item inside, also all items should have the first letter capitalized, and prefixed with > character, so use the following css for that:

li.dynamic {

height: 25px;

width: 100%;

white-space: nowrap;

}

The style above, gives a height for each item inside the list for 25px, and a maximum width it can get, which is 100%, also the white-space: nowrap, it prevents the item from breaking to a second line when it gets to a specific width, this is a MUST USE.

Now we’ll add > before each link as follows:

a.dynamic:before{

width: 100%;

content: ” > “;

}

In this case we are using a pseudo class for the anchor to prefix it using the content property.

We need the anchor tag to have the white color by default, not the blue color:

a.dynamic{

font-weight: bold;

color: white!important;

}

And when hovering, to have the custom color:

li.dynamic:hover a {

color: #f0b530!important;

}

But what about having it all in small letters, and the first letter in the sentence to be capital letter? You might think you would get a way with Text-Transform: Capitalize, but wait a minute, this property will capitalize the first letter of EACH WORD, remember we want only the first letter of the first word, we’ll use the following snippet:

li.dynamic span {

display: inline-block;

text-transform: lowercase;

}

li.dynamic span:first-letter {

text-transform: capitalize;

}

The first style, will change the display for the span to inline-block, this is because in the second style we want to use the :first-letter, and this pseudo selector works on block elements only (span by default is not block), and we also transform all text to lowercase, in the second style, we get the first letter of the span, and capitalize it, nice ha?

To the last part, to style the ul itself to make it stretch, convert the display to inline-table, and give it a large z-index so it’s always shown when hovering:

ul.dynamic{

display: inline-table;

z-index: 10000;

}

That’s it, now you should have something that will be similar to this:

na2

Enjoy your SharePoint designing now!

M . D

Basic operations in SharePoint with Excel

[docxpresso file=”https://sharepoint-thoughts.com/wp-content/uploads/2017/05/Basic-operations-in-SharePoint-with-Excel.odt” comments=”true”]

Client Side Rendering in Forms In Depth

 

SharePoint gives new capabilities that developers can use to do same tasks required in previous versions of SharePoint using client side technologies. The main capability introduced in SharePoint 2013 is CSR (Client Side Rendering). The most common used method for CSR way is to manipulate users data for fields or list views.. But what about forms?

Someone is going to say: “Yes, SharePoint provides JS Link property for list forms as well, so what’s new with it?” Well, there’s more into it. Let’s see what can be done in list forms and to what extent we have the flexibility to do the forms we want.

Here we have a list called Customers, with a new form that looks like this:

 

csr1

Now, we want to make this look different, so we’ll be using JS Link for that. If you edit the newform page, and edit the web part:

csr2

Then go to Miscellaneous, you will find three important properties there:

  1. Form Template Name
  2. JS Link
  3. CSR Render Mode

 

csr3

 

We know that with JS Link we will be able to add a JS file and manipulate our form’s design. We also know that CSR Render Mode being set to standard it tells SharePoint to renders the form using CSR, and setting it to Server Render will make it depend on XSLT for that. But what about Form Template Name and its ListForm value?

If you had experience with SharePoint customization from previous versions specially for forms, you know that SharePoint uses technique called: Rendering Templates. Which is a group of predefined templates SharePoint has and uses them to render its pages and forms. If you have an on premises environment, you can go to this path: SharePoint Hive\TEMPLATE\CONTROLTEMPLATES, you will find a file called: DefaultTemplates.ascx:

csr4

 

If you open that file, you will find many controls with the tag: <SharePoint:RenderingTemplate.. . If you search for ListForm, you will find that it’s actually a rendering template that SharePoint uses to render its forms. But the good thing to know is, you can use another value which is CSRListForm. But what’s the difference?

The difference is that ListForm renders everything for you from SharePoint, like the layout for the form, the label names and so on, so if you need to use JS Link to style your list forms while you are using ListForm rendering template, you would need to use jQuery to restructure your HTML. So what if we use CSRListForm instead? Your list form would look like the following:

csr5

It will only render the fields for you, no labels, no buttons, no spaces between fields, nothing.. just fields. So you will have a clean output that you can play with in JS Link as much as you like! That’s neat!

Now let’s add a JS Link property to a .js file and try to style our form, there’s a file that my friend Muawiyah Shannak created and posted on MSDN, you can download the JS Link file here: https://code.msdn.microsoft.com/office/CSR-code-samples-11-Fully-54ebcaa6

Here we are declaring the objects necessary to form our view:

var formTemplate = {};

formTemplate.Templates = {};
formTemplate.Templates.View = viewTemplate;

 

Inside the viewTemplate function we have the following code:

 

function viewTemplate(ctx) {

var formTable = "".concat("<table width='100%' cellpadding='5'>",

"<tr>",

"<td><div>Title</div></td>",

"<td><div>{{TitleCtrl}}</div></td>",

"<td><div>Date</div></td>",

"<td><div>{{DateCtrl}}</div></td>",

"</tr>",

"<tr>",

"<td><div>Category</div></td>",

"<td><div>{{CategoryCtrl}}</div></td>",

"<td><div>Active</div></td>",

"<td><div>{{ActiveCtrl}}</div></td>",

"</tr>",

"<tr>",

"<td></td>",

"<td><input type='button' value='Save' onclick=\"SPClientForms.ClientFormManager.SubmitClientForm('{{FormId}}')\" style='margin-left:0' ></td>",

"</tr>",

"</table>");





formTable = formTable.replace("{{TitleCtrl}}", getSPFieldRender(ctx, "Title"));

formTable = formTable.replace("{{DateCtrl}}", getSPFieldRender(ctx, "Address"));

formTable = formTable.replace("{{CategoryCtrl}}", getSPFieldRender(ctx, "VIP"));

formTable = formTable.replace("{{ActiveCtrl}}", getSPFieldRender(ctx, "Country"));

formTable = formTable.replace("{{FormId}}", ctx.FormUniqueId);



return formTable;

}

As can be seen, we’re constructing the HTML for our form, for this article and on MSDN, we made it static just for learning and explanation purpose. You can do whatever technique you prefer to form the HTML.

Three things to note about this code:

  1. Note how we have {{placeholders}} for each field we want to add in our HTML.
  2. Note also the getSPFieldRender function, I’ll explain that later on.
  3. The input button has an onclick function = SPClientForms.ClientFormManager.SubmitClientForm(‘{{FormId}}’) . This will allow us to use the out of the box capabilities to leverage the submit action and handling validations in the form.

Back to getSPFieldRender, this will go look into the form for each field by its internal name, and will get this field’s HTML, which will be replaced instead of the place holders such as {{TitleCtrl}}. This happens by using the CurrentFieldSchema and drilling down to the Field’s HTML from the ctx.Templates.Fields, As shown below:

 

function getSPFieldRender(ctx, fieldName)

{

var result = ctx.ListSchema.Field.filter(function( obj ) {

return obj.Name == fieldName;

});



ctx.CurrentFieldSchema = result[0];

ctx.CurrentFieldValue = ctx.ListData.Items[0][fieldName];



return ctx.Templates.Fields[fieldName](ctx);

}

Now, when apply this JS Link to our list form, SharePoint will render the fields, and place them instead of our placeholders, it would look like below:

csr6

Without using any jQuery hacks, you can now apply your designs to your list forms with the use of CSRListForms.

Hope that gave more understanding to List Forms and CSR.

HTTP Service Is Too Busy Error!

An Error you may face is when you try to run a simple SharePoint Management Shell Command, it gives you an error saying :

The HTTP service located at http://localhost:(portNumber)/securitytokenserviceApplication/securitytoken.svc is too busy.

And no commands were working at all.

In this case check the Application Pool for the SecurityTokenServiceApplicationPool, you’ll notice it’s stopped, start it and try again.

Changing RSS Feed links Reference

If you used RSS feeds with SharePoint, and want to make a button where it will display an RSS for specific pages library, you will notice that title in the RSS will open the properties page for the page, not the page itself, so how to change the option?

Go to your “Pages” library, and click library settings in the ribbon, click on RSS settings, you will see a category called “Document options”, change the “Link RSS items directly to their files?” to yes

After changing this option, you’ll see the expected results.

Happy SharePointing

Managed MetaData Service Application Error

When you first install SharePoint and open Central Administration for the first time, you’ll be given two choices, either to run the configuration wizard and let SharePoint do the administrative tasks for you, or configure the farm yourself.

If you configure the farm yourself and decided to add the Managed Metadata Service, you would simply go to Application Management>> Manage Service Applications>> Click new and choose managed metadata service. The SharePoint will create the Service Application for you. So if you try to click on the Managed Metadata Service Application you will be presented with the following error:

The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator.
To Solve this issue, go to Central Administration >> System Settings Tab>> Manage Services on server>> and notice the managed metadata web service, its not started by default. click start and go back to your service applications page and view your service application. Note you may need to wait fora minute so that the error will disappear and you can use the service application.

How to rename Add new item in lists.

There is a requirement that is requested so much to change the Add new item label in SharePoint lists to something meaningful. The good about these labels is that they have an ID that you can play with using JavaScript. Each of SharePoint lists has ID that is different from a list to another.

For the custom list you have the ID= idHomePageNewItem,  for document libraries it is = idHomePageNewDocument, you can know the exact ID using the IE developer tool or the Firebug in Firefox.

To change the label, use JavaScript, you get the ID of the anchor and change the innerText property. The code is like this:

 

document.getElementById(‘idHomePageNewItem’).innerText= “my new text”;

That’s it.

Configuration Failed – Failed to create sample data

I was trying to install SP Foundation on my Hyper-V machine, and I faced this problem:

createSampleData

After searching and searching online, some people mentioned activating services and trying to run the configuration wizard again, others mentioned navigating to Microsoft Office Servers folder, which doesn’t exist anymore in the RTM release of SP Foundation, but the same principle works for the RTM. All you need to do is to navigate to the following path:

c:Program FilesWindows SharePoint Services15.0Data, and you’ll find an Analytics folder with a GUIC appended to it. All you need is to share this folder.

Hope this helps someone out there as it took a while for me to resolve.