Extra column in Content Query WebPart not showing

So one quick tip..  I had a requirement to add an extra field for a CQWP, and map it to display a column inside my target list, Here is a mistake that took me a while until I figured it out:

So to add a new field, we modify both ItemStyle.xsl and the .webpart file to include our new field, right?

I have my field inside my list called: SecondLocation, so in our Template inside the ItemStyle.xsl, we add this field inside a div or any other html control we may need, in order to style it, like this:

<xsl:value-of select=”@SecondLocation”/>

Now we will add this field to the webpart itself, because it’s not there by default, so we export the webpart, and add this field to the “CommonViewFields” section, what I did is like this:

<property name=”CommonViewFields” type=”string”>
SecondLocation, Text
</property>

When I tried to view the webpart, I didn’t see my field displayed, Although the internal name is right, the field is written in ItemStyle.xsl, the field is added to the .webpart file, the thing is with the formatting of the xml for the .webpart itself, instead of writing the properties for the webpart on multiple columns, you should write it all on the same column, like this:

<property name=”CommonViewFields” type=”string”>SecondLocation, Text</property>

Get manager Information for current user in InfoPath 2010

In this article, I’m going to demonstrate how to get the current user’s manager’s information.

We all know the usage of userprofileservice.asmx in InfoPath 2010 and how we can extract data for the current user using this web service. But what if we want to get information for user’s manager, like first name and last name. In this case we need to add a second data connection, this data connection is going to behave as a source to get manager information. To do this, click Data from the ribbon, then add data connection to userprofileservice.asmx and getuserprofilebyname , call it Profile Second Connection.Now we will have these 2 data connections in the data connection section in InfoPath 2010 as the following:

 

Add a field to the main data source call it manageraccountName, you do this by right clicking on the myFields folder in the right pane, and add a field,  and use the Profile First Connection to get the manager account name into this field, you do this by opening field’s properties, click the Fx button next to default value, click insert Field or Group, Change the data source to Profile First Connection, Expand the data fields until you reach the value field, click one click on the value, and click filter data, in the filter data popup, click add, change the left dropdown list to “Select a field or group”, in the select field or group popup choose the “Name” field, click OK, in the right dropdown list write “Manager”, and click OK for everything.

Second step is to put action on this manager field, this action is going to set the field value for the Profile Second Connection to its value. It’s a complex process but follow my steps literally.

Click on the manager account name field, click manage rules, add a new rule and make an action inside it, the action is of type Set a Field’s value, for the field click on the button to choose the field, from the data connection drop down list as in the following picture:

choose the Profile Second Connection, Expand the queryFields and the group below it, and choose AccountName, Click OK, see the below picture:

In the Value field, click the Fx, click insert field or group, and choose current field (manageraccountName).

Now that you have set the value for the accountname in the Profile Second Connection to the managerAccountName, do the following steps:

1- Add new field to main data source,  called managerFirstName.

2- In the data source, change the data connection to Profile Second Connection, Expand the queryFields, then the group under it, and click AccountName, then click manage rules, Add action rule.

3-The first action will Query the Profile Second Connection,

4-The second action will set the field managerFirstName, to the value of the Profile Second Connection value where property name = FirstName, as we always do with the current user when we get his information.

See the following 3 Screenshots:

Select managerFirstName from the set field’s value wizard:

Choose the second data connection for the value of the field, click value, then click filter data,

In the filter data, choose the Name from the wizard, and type FirstName, this will get the manager’s first name.

Hope this helps people out there.

Mohamed Derhalli.

Updated: Added Screenshots as requested in the comments.

IFilter For PDF Files

We know that indexing in SharePoint doesn’t index PDF files. because PDF Files are not products for Microsoft. SharePoint only searches documents that there is an Ifilter released by Microsoft for them such as : .docx, .xlsx, .one

So we now know that .pdf is not supported by default in SharePoint. So we need to install the Ifilter for pdf on our server.

Once you download it, make the setup and then IISRESET.

So we have the Ifilter installed on our server, now we need to tell SharePoint to start indexing pdf files.

Open Central Administration >> Application Management >> Manage Service Applications

Then Choose Search Service Application. At the left navigation you will find a link called “File Types” under crawling category. which means the file types that are going to be indexed by SharePoint, click it.. You will see a page with all file types that are going to be indexed.

Click New File Type, and enter PDF.

Now SharePoint is going to index your PDF files. Note that when SharePoint searches for a word document it will view the word icon beside the documents. But when searching for PDF document it will not view the PDF icon beside the results because PDF icon is not listed in list of icons that SharePoint recognize.

So we have one more thing to do to make this perfect!

We’ll add PDF icon, you can get this one. 

Name it pdfimage.jpg and save in 14TemplateImages

Now navigate to 14TemplateXML and search for a document called DOCICON.XML, open it in a text editor tool, you are going to see a tag called <ByExtension>. This tag contains records for icons supported by SharePoint like ppt for Microsoft PowerPoint and key name one for Microsoft OneNote. We will have to add a key for PDF files, so just add this record <Mapping Key= “pdf” Value= “pdfimage.jpg”/> (you can see that this file looks up images from the images folder). save the file. Now try to search for a document with PDF type, you will find that the icon appears.

Have a nice search ! 🙂

Crawling Rules in SharePoint 2010

Some times when you make search results page, you may notice that there are some pages in the results that link to internal pages for lists and libraries, site settings page, and so on. And you don’t want these pages to appear for end users.

I have seen posts on the internet where people were in need to hide these links, they were trying to find out ways to change the XSLT for the search results web part. But the question is, why to retrieve these pages in the first place?

You can always make a crawl rule, that allows you not to crawl specific page URLs and in this way, these pages won’t be rendered in the search results web part.

You can reach the crawl rules by opening central administration >> Application Management >> Manage service applications >> Choose Search Service Application >> below crawling category click  Crawl Rules.

Here you can add rules that can exclude links from being crawled. Click New Crawl Rule, Type something like this: *://*/allitems.aspx and click OK. This will exclude all pages that have allitems in their URLs. Doesn’t matter if they were http or https because we wrote *

Hope this would help understanding the use of crawling rules and how would they be used in real situations.

Creating PopUp dialog boxes in SharePoint 2010

You wonder how to create pop up dialog boxes in SharePoint 2010? If you have a page of yours and you don’t want the user to navigate to another page to see it. You only need an anchor to be able to do so. just write this line of code in your page:

<a href=”javascript:OpenPopUpPage(‘http://…….’)” mce_href=”javascript:OpenPopUpPage(‘http://…….’)”> Open PopUp </a>

This will open your page without navigating away from the page you are on.

Add WebPart to your master page?

We know that webparts in the master page are not configurable, unless you configure them in SharePoint designer. If you edit the page, it won’t be editable. and we hear about putting a webpart inside the master page so it appears everywhere. Or maybe your manager told you to put the webpart inside of each page layout that’s developed by another developer. But how to achieve this?

Let’s first add our custom webpart to a webpart page stored in the pages library (or any other library but it makes sense to put it in pages library).  Name it fortest (name doesn’t matter because you won’t be using it anymore after you finish this process).

Now you have a webpart page, add your custom webpart to this page.

Now you’ll have to play with SharePoint designer to put this webpart inside your master page.

Open up SharePoint designer, and navigate to your webpart page. You can see it by clicking All files from the left pane, then you’ll find your pages library in the right pane, click it and then double click on the fortest.aspx to edit the page. It will display something like this:

 

You’ll find a registry entry at the beginning of your code, copy it and save it in a text editor. Then scroll down to your webpar, it will be something beginning with <WpNs0:Testwebpart runat=”server” ID=”

Copy it and save it in the text editor.

Now delete the webpart page, we don’t need it anymore. And open your master page. At the beginning of the master page, paste the registry entry that you copied from your webpart page below the other registry entries. now we’re done from the first part. To the second part, paste what you copied from the webpart page which represents the webpart itself which begins with  <WpNs0:Testwebpart runat=”server” ID=”… at whatever place you want it to  appear inside your master page. You can paste it below the footer or wherever you want.

To sum it up: you need to add your webpart to a webpart page, and then copy 2 entries from it, the registry entry which registers the webpart in the page, and the webpart entry itself.

Port Restricted For Security Reasons

Sometimes when working on your development machine and using firefox, you may get the error:

 

this is because firefox may block some ports by default, such as 530, 531, 540, so what would you do? remove your web application and make it on another port? well, no! you can easily unblock firefox port as follows:

Type the following in the address bar in firefox:  

about:config , you will be presented with security message telling you that changes may affect performance and security, click the button to continue.

Now right click on anywhere in the list, and choose NEW>> STRING, a window will open to enter the name for this record, type : network.security.ports.banned.override

 now you will be presented with another window, enter the value for the port you want to unblock, such as 530. and hit OK.

 close your browser and go back to your SharePoint site and enjoy.

Master Page Editing Has Been Disabled.. Error

You may have faced this message when you tried to edit a SharePoint 2010 site’s master page:

 

Master page editing has been disabled for this site. Contact the site collection administrator to request permission.

 

 

This is caused in 2 cases: first case if the site collection administrator has stopped the permission to edit the master pages for the site collection, so if you are a site collection administator go to site settings, and under site collection administration you can see the button “sharepoint designer settings”, make sure that customizing master pages is enabled, if its disabled and you can’t do something about it, then this is case 2 : it’s disabled from the web application itself, so now you have to go to your web application settings using central administration tool, and on the general application settings tab, choose sharepoint designer settings, and enable the same option.

 

Note: Site owners can’t edit master pages unless site collection admin allow the feature, and site collection admins can’t allow it unless farm admin allow it at the web application itself.

 

How to use Developer Dashboard

all of us know the usage and benefits we get using Developer Dashboard in SharePoint 2010. But This Dashboard is not enabled by default in SharePoint. You (The SharePoint Administrator) can enable it using either STSADM or the SharePoint Management Shell.


Here, you will see how to enable Developer Dashboard using PowerShell, and the options you get for the Dashboard mode.

Start by opening SharePoint Management Shell, you can find this by going to Start>>All Programs>>Microsoft SharePoint 2010 Products >> Right click the SharePoint 2010 Management Shell and choose Run as administrator.

You need to know that there are 3 modes for the Dashboard, which are On,Off, and OnDemand.

These modes explain themselves. On Mode enables the Dashboard so the Site Collection Administrator will view it whenever he opens the page, he doesn’t have the option to turn it off. The Off mode Disables the Dashboard on all pages and the Site Collection Administrator has no option to get it on. The OnDemand option makes it possible for the Administrator to turn it on or off when required.

How to use Managed Metadata Service Application

In this walkthrough, I am going to show you how to configure the Managed Metadata Service Application and use it to make custom column and examine the filtering options in SharePoint 2010.

 When configuring Managed Metadata Service Application, you can add Managed Metadata Columns to your libraries and lists in the site collections which consume the Service Application Services. To understand the managed metadata service application you need to be familiar with the term store. The term store is where you make groups for your terms which are managed by term sets. Take a look at the picture below:


This is the term store management tool. Suppose you want to make a term set for countries so you can use it in lists. on the left side click your service Application Name and choose New Group

 


 This group will be a location for storing term sets like countries. Here i named the group “my first group”.

Click on the group and choose New Term Set, name it countries. here you will add the countries you want to appear in the suggestions in your managed metadata column.


In the same way, add two countries now for testing purposes by clicking “Create Term” from the options at the term set.

Go Back to the term set and View its option on the right as shown below:


 There are 2 important options here, the submission policy, and the Available for Tagging option. The submission policy has 2 options, closed and open. If open, it allows users to add their own terms to the term set whereas closed prevents users from adding more terms and limits them to just use what’s available.

The Available for Tagging takes the term set offline and doesn’t show the terms for users. lets keep it as it is now.

So lets go to a Site Collection that consumes this Service Application and Create a new list and add a custom column of type “managed metadata” to see what it provides.

I made a Custom list named Products and added a column named “Source Country” of type managed metadata. when creating the column note that in the term set settings.


You need to choose the service application you will use in case there is more than one service application, you will see the groups you made, and the term set, click on the countries option and click OK.

Click add new item, let’s put polo shirts in the title field and type U letter in the source country column. Notice you’ll be given the option to choose UAE. Try clicking the button at the right of the column , you will see something like this:



An important note is that if you enabled the submission policy in the term store management tool, you will see an option here to add new term to this term set, but because we chose to not enable it, no link is available now.

let’s add another 2 products for UAE and 2 for Jordan. as in the picture below:


So let’s examine the filtering and navigation settings in SharePoint using this column. click on the arrow next to the column name and choose a country:

The list will be filtered to show the desired results. this option is known in SharePoint 2007 too, so let’s try something different.

Click the list tab, and then list settings. Choose Metadata Navigation Settings

 Now choose the source country in both options (Don’t be in a hurry, You will understand now what they do). and click ok and get back to the list. See the below image


Now look at the left of your page as shown in the pic below

 


From the first option you can choose the column (source country) that  you have selected in the metadata navigation settings in the hierarchy options(this was the first option in metadata navigation settings) Now you can filter using this option, or if you look at the option below it and filter using key filters which retrieves the data as the source country column you made.(this was the second option in metada navigation settings)