SharePoint 4 Developers

Additional reference guide in .NET / SharePoint Development

Grouping by Content Type is missing in View Settings

In SharePoint 2010, the option for grouping by Content Type is missing, no longer available for users! What to do in this case? SharePoint Designer 2010 helps us to solve this problem.

Hi folks,

Currently I am working on a SharePoint 2010 Migration (from MOSS 2007). Most part of the work is done by scripting, however some tasks can be done manually because is much faster.

I include in these tasks quick fixes, which can be made by the user interface. Just telling that, because I had to repair some views that contain groupings and noticed that in SharePoint 2010, the option for grouping by Content Type is no longer available for users! What to do in this case? SharePoint Designer helps us to solve this problem.

Simulating the creation of view grouped by Content Type

A user needs to create a view that groups items by Content Type. How to accomplish this task?

In the Figure 1 there is a Document Library which contains some documents. Select the option Create View directly through this visualisation.

Create View Figure 1 – Option for creating a view

The next step is to choose the view format, in this case a Standard View can be chosen, according to the Figure 2:

Standard View Figure 2 – Choosing the view format

Name the view to Grouped by Content Type (for example), according to the Figure 3, then go to the Group By section and select the option Content Type according to the Figure 4. Oops…Where is it? In MOSS 2007 that was available!

View Name Figure 3 – View Name

Grouping Figure 4 - Column selection for grouping by

The Content Type option is no longer available in SharePoint 2010! In order not to encounter such pranks during the SharePoint 2010 Migration, do usability testing with real users, because they work everyday with SharePoint and know what is essential for their daily tasks.

Using the UI there is no exit, just save the view.

Workaround utilising SharePoint Designer 2010

Open the SharePoint Designer against the Web Site in which the Document Library was created, according to the Figure 5:

SPD2010 Figure 5 - Document Library

Skip to the opening of the newly created view according to the Figure 6:

SPD2010 View Figure 6 - Newly created view selection

In regards to the Grouping By section, this is the XMLDefinition snippet that was created automatically after saving the view. In other words, it is empty! As we can see in the Figure 7, just the description of the empty element Query is available:

XMLDefinition1 Figure 7 - Empty XMLDefinition Snippet

Alter this code snippet to contain the group by Content Type as per Figure 8. It does the trick:

XMLDefinition2 Figure 8 - Grouping by defined in the XMLDefinition

The same code snippet is below for copying:

Code Snippet
  1. <GroupBy Collapse="TRUE" GroupLimit="100">
  2.   <FieldRef Name="ContentType"/>
  3. </GroupBy>

Note: This code snippet defines the grouping by Content Type, besides, it defines that items will be collapsed by default and limited for displaying 100 items per grouping by.

In the end here we have the expected outcome, according to the Figure 9:

Outcome Figure 9 - Final Outcome

Finally we've got the expected outcome! A task that was simple before, now just can be done with the utilisation of a tool, and just in case the user has privileges for that.

Reference:
SharePoint Developer Center Forum

Cheers,

Marcel Medina

Click here to read the same content in Portuguese.

Business Connectivity Services – Part II

Learn about the Business Connectivity Services and how to develop solutions using the SharePoint Designer 2010 and Visual Studio 2010 by creating External Content Types via Database. (Part II)

Hi folks,

This post is the continuation of the Business Connectivity Services Series, focused on development. In this approach I demonstrate how to create ECTs via Database.

External Data Access

For all the examples, consider using the following table Contact. It needs to be created, as this will be used as our base table for exemplification:

Code Snippet
  1. CREATE TABLE [dbo].[Contact](
  2.     [ContactID] [int] IDENTITY(1,1) NOT NULL,
  3.     [CompanyName] [nvarchar](100) NULL,
  4.     [ContactName] [nvarchar](70) NOT NULL,
  5.     [ContactTitle] [nvarchar](10) NULL,
  6.     [Address] [nvarchar](100) NULL,
  7.     [Email] [nvarchar](100) NOT NULL,
  8.     [City] [nvarchar](15) NULL,
  9.     [Region] [nvarchar](15) NULL,
  10.     [PostalCode] [nvarchar](10) NULL,
  11.     [Country] [nvarchar](15) NULL,
  12.     [Phone] [nvarchar](24) NOT NULL,
  13.     [Fax] [nvarchar](24) NULL,
  14.     
  15.     CONSTRAINT [PK_Contact] PRIMARY KEY (
  16.     [ContactID] ASC
  17.     )
  18. )

Create it against the SQL Server, because the ECTs are going to be created based on this table. The task of creating a table I am not going to approach, once this is not the purpose of this article (Please check the references for links to perform that).

Creating ECTs via Database

In order to create ECTs via database only SPD2010 is required and nothing more.

Use this type of approach in environments:

  • That are in the same network, where the database access can be done directly through SPD2010;
  • There is no need of creating business rules, just because CRUD operations are sufficient;
  • That uses SQL Server database (that´s right, only SQL Server);

If you have this scenario, this demonstration is the easiest and simplest way to implement.

Working with SharePoint Designer 2010

Start the SPD2010 (through SharePoint 2010 or open this tool directly) and access External Content Types in the Navigation pane. Create a new ECT and set the properties according the Figure 1:

Figura 1 Figure 1 – Creating an ECT

Note: The properties Office Item Type and Offline Sync for External List determine the mapping type of objects in Office 2010 and if the sync option will be available for External Lists respectively. Pay attention to the selection areas in red colour that display the steps to perform the configuration, which can be enumerated to indicate the correct steps.

When clicking over the External System for mapping the ECT, the Figure 2 is displayed:

Figura 2 Figure 2 – Adding a new connection

Add a new connection (1) that maps the SQL Server database by selecting it in the External Data Source option (2). Set the connection parameters according the Figure 3:

Figura 3 Figure 3 – Connection details

Nesse When connecting with User´s Identity, the SQL Server uses the login of the current user logged in SharePoint to display data. Proceed with the operation and find the table Contact. In order to create a CRUD, select the option from the context menu (right button) Create All Operations according the Figure 4:

Figura 4Figure 4 - Creating all the operations of a CRUD

Note: In this example we have a CRUD, which contains all the operations, but if you opt for the creation of some operations only, the operations Read Item and Read List needs to be created (at least). Otherwise you cannot create an External List, which represents a SharePoint list that displays external data.

A modal screen is displayed at the moment of picking out an operation. On this screen set the parameters of the CRUD, according the Figure 5:

Figura 5Figure 5 - Parameters configuration screen

Basically we need to configure the column properties of the table Contact, setting an identifier, display names, required fields and the mapping for the Office properties (Outlook). All the definitions are available in the Tables 1 and 2.

Data Source Element

.NET Type

Map to Identifier

Identifier

Field

Display Name

Foreign Identifier

ContactID

System.Int32

TRUE

ContactID

ContactID

ID

 

CompanyName

System.String

FALSE

 

CompanyName

Company Name

 

ContactName

System.String

FALSE

 

ContactName

Contact Name

 

ContactTitle

System.String

FALSE

 

ContactTitle

Contact Title

 

Address

System.String

FALSE

 

Address

Address

 

Email

System.String

FALSE

 

Email

E-mail

 

City

System.String

FALSE

 

City

City

 

Region

System.String

FALSE

 

Region

Region

 

PostalCode

System.String

FALSE

 

PostalCode

Postal Code

 

Country

System.String

FALSE

 

Country

Country

 

Phone

System.String

FALSE

 

Phone

Phone

 

Fax

System.String

FALSE

 

Fax

Fax

 
Table 1 – CRUD Parameters

Data Source Element

Required

Read-Only

Office Property

Show In Picker

Timestamp Field

ContactID

FALSE

TRUE

Custom Property

FALSE

FALSE

CompanyName

FALSE

FALSE

Company Name (CompanyName)

FALSE

FALSE

ContactName

TRUE

FALSE

Full Name (FullName)

FALSE

FALSE

ContactTitle

FALSE

FALSE

Title (Title)

FALSE

FALSE

Address

FALSE

FALSE

Business Address (BusinessAddress)

FALSE

FALSE

Email

TRUE

FALSE

Email 1 Address (Email1Address)

FALSE

FALSE

City

FALSE

FALSE

Business Address City (BusinessAddressCity)

FALSE

FALSE

Region

FALSE

FALSE

Business Address State (BusinessAddressState)

FALSE

FALSE

PostalCode

FALSE

FALSE

Business Address Postal Code (BusinessAddressPostalCode)

FALSE

FALSE

Country

FALSE

FALSE

Business Address Country/Region (BusinessAddressCountry)

FALSE

FALSE

Phone

TRUE

FALSE

Business Telephone Number (BusinessTelephoneNumber)

FALSE

FALSE

Fax

FALSE

FALSE

Business Fax Number (BusinessFaxNumber)

FALSE

FALSE

Table 2 – CRUD Parameters (Continuation)

Note: Fields in gray colour have two meanings in Tables 1 and 2:

  • Fields cannot be edited; or
  • Ignore the field configuration because it does not apply to our scenario;

The field Data Source Element is the reference used in both tables.

Once all the column properties were set properly, save the ECT (1) and note the operations created (2), which can be edited at any time, according the Figure 6:

Figura 6Figure 6 – Saving the ECT

At this moment it is already possible to create an External List that will display the external data in SharePoint 2010. In this same screen of External Content Types, select the option External List on the context menu. Name it to Contacts, according the Figure 7:

Figura 7 Figure 7 – Creating an External List

From this point on we only need to test the External List to see its functioning.

Testing an External List

This is the final step of creating ECTs, in which the CRUD operations are going to be tested against the External Lists. In order to do that, access the SharePoint Site where the External List Contacts was created.
Open it and add a new item. Note that the configuration of parameters were applied into the columns, according the Figure 8:

Figura 8 Figure 8 - Adding a new item on the Contacts List

Immediately after adding the new item, check whether it is available at your table in the database. There it is, right? This is the expected behaviour after adding a new item, furthermore, the other CRUD operations must be active in the List Contacts according the Figure 9:

Figura 9Figure 9 - Checking the CRUD operations

Perform the remaining operations and check against the database the expected behaviour.

In this post we explored the SharePoint Designer 2010 to create ECTs, however in the next posts of this series the Visual Studio 2010 will be utilised as additional tool. In the next post check how to create ECTs via Web Service. See you then!

References:
http://msdn.microsoft.com/en-us/library/ee556826(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/ms186378(v=SQL.105).aspx

Cheers,

Marcel Medina

Click here to read the same content in Portuguese.

Creating workflows in SharePoint 2010 – Integration Part II

This videocast brings the Part II of how to integrate Visio 2010, SharePoint Designer 2010, InfoPath 2010 and Visual Studio 2010 in order to create workflows in SharePoint 2010.

Hi folks,

After a while without publishing videocasts, I have got a time to focus on the creation of workflows in SharePoint 2010.

This videocast brings the Part II of how to integrate the 2010 version of Visio, SharePoint Designer, InfoPath and Visual Studio in order to create workflows in SharePoint 2010.

Here's a link to access the videocast available on vimeo :



Here's a link to access the same videocast available on screencast :



Video Download: Creating Workflows in SharePoint 2010. Integration Part II.

Description: This videocast is the second part of how to integrate the 2010 tools: Visio/SharePoint Designer/InfoPath/Visual Studio. It is in Portuguese language.

Cheers,

Marcel Medina

Click here to read the same content in Portuguese.