SharePoint Developer Orientation – Part 4: Advanced Customization with Designer

Learn how to use SharePoint Designer to declaratively develop advanced customizations.
Page Content

 

2011-07-17-SPDevOrientation-Part01-01.jpgSharePoint Designer is your friend

Now that you are generally familiar with SharePoint from a user’s perspective, it’s time for advanced customizations with SharePoint Designer. This tool is for customizing specific SharePoint sites and adds a lot of functionality over the Web UI (workflows, form customizations, Business Connectivity Services, etc.). It is a powerful and useful tool, even if buggy, prone to crashes, and slow.

The goal of any SharePoint project is to leverage the use of the platform, deliver value rapidly, and enhance the user’s capabilities to serve their business needs. Depending on the type of project you are working on, Designer can be your destination or your vehicle. If this is a single-site customization project, for example, try to stop at the web UI and Designer. If this is a professional solution with complex implementation, deployment, or maintenance requirements, you will still use Designer regularly. Oftentimes, it is the only way to learn how something works, or at least the best way to get started. You will then import your customizations into a Visual Studio solution to package them up, and deploy them, and likely add code (web parts, workflow activities, event receivers, etc.).

Customizing list views and forms

One of the most common and likely customizations you will come across is customizing list views and forms. In the web UI, you can customize a view by showing or hiding columns, adding filters, sorting, grouping, and that sort of thing. You cannot, however, touch how the list data are rendered. Each field will display the same way every time depending on its type. The headers, the hover effects, and all the elements of that list are predetermined. SharePoint Designer gives you the tools to go deeper.

SharePoint uses an XSLT rendering method that applies the XSL Transformations to the results of a query to render a list view or form (display, edit, or new). The actual transformation happens early in the page lifecycle during page initialization, allowing the use of ASP.NET server control declarations in the XSL. You will see the <SharePoint:FormField … /> control in new and edit forms, for example, that renders the complex controls for editing data depending on the field type. Also, SharePoint provides added functionality by importing some xml namespaces for use in your XSL markup. So, when customizing a view or form, you have the power of XSLT to work with, plus the SharePoint ddwrt namespace, plus the use of ASP.NET and SharePoint server controls.

To get started, check out this great SharePoint Designer resource from Microsoft. The Data Views and Forms link has a wealth of information on how to use the tool to customize views and forms using Designer. Each article has a See Also section near the top of the right margin with related articles. Some notable examples:

    • Example 1: Create a custom list view Just to give you an idea, here is an example from a recent sample project I worked on. Here I used HTML (added div elements and the like to the XSL), jQueryUI and CSS to translate numeric or text values into meaningful visualizations:

Before:

2011-09-23-SPDevOrientation-Part04-01.png

After:

2011-09-23-SPDevOrientation-Part04-02.png

    • Example 2: Create a custom list form Once again, example screenshots to spur the imagination. Here I formatted the fields as Text Boxes instead of SharePoint FormField using the Design view. I then switched to Source view and added jQueryUI sliders and synced them with the textbox. To add more sizzle, I swapped out CSS classes for the slider depending on ranges I chose. Green for 0 – 0.35, etc.

Before:

2011-09-23-SPDevOrientation-Part04-03.png

After:

2011-09-23-SPDevOrientation-Part04-04.png

Before we move on, I have to mention Marc Anderson, one of the most active members of the SharePoint community serving “the middle tier”. Call it what you will, this advanced customization, declarative programming, or middle tier development that I described above is very powerful. Check out his blog, and the SPServices jQuery library.

Designer workflows

You can create workflows to help automate business processes using the many OOTB workflow actions and pre-canned workflows, like approval and signature collection. Workflows open the door to processing data that you don’t have in the web UI. A workflow is just code that runs on the server with inputs, outputs, access to variables, etc. This is Workflow Foundation under the covers. So using the existing workflow actions, you can process data in new ways. For example, since some fields aren’t accessible in a Calculated column (like ID or lookup fields), you can use a workflow as a replacement. The workflow is scheduled to run asynchronously in a timer job after the list item is created with no guarantee of when it will run, so it may not be ideal in all situations. Any workflow-modified fields will not be immediately available to the user and could take a few minutes to update.

You cannot create new actions or write new workflow code in Designer, but you can augment your toolbox. Here is a great opportunity to gradually scale up your project. If you find you cannot accomplish something with a Designer workflow, you can find open source components (check codeplex.com) and third party products (from activities to advanced workflow design software). Failing that, as a developer, you will certainly be able to write your own as well. It goes against our instinct as developers, doesn’t it? If Designer workflows are too limited, we want to pull it into Visual Studio and use the full power of Workflow Foundation. We don’t want to use some contrived designer to perform actions that would take only a line or two of crisp, clean code. Remember… the point is to deliver low-cost, low-complexity solutions. Purchasing a workflow action is cheaper, more reusable, and easier than custom code. Of course, when warranted, there is nothing better than custom code, but think reusability. Write a custom action to get over a hump before writing a completely custom Visual Studio workflow.

What else?

A few other important capabilities to be aware of are:

  • InfoPath: If you are using SharePoint Server, you also have access to InfoPath forms for form customization. InfoPath includes a rules engine, validation, more form layouts, and controls, and the ability to write code within the form.
  • Business Connectivity Services: BCS allows you to integrate external data and functionality into your SharePoint 2010 environment. This great article by Kirk Evans describes what BCS is, how to use it, and even proper scenarios for custom development beyond Designer.
  • Honorable Mention: Well, as this post fizzles out, I’ll mention that Designer has other capabilities that you can explore on your own. Editing pages, editing master pages, and site/sub-site creation all get an honorable mention.

In conclusion, I hope you see that an awful lot can be done in SharePoint using the web UI and Designer. Even if you remain strictly a custom coder, there is a place for you in this ecosystem. Everything we have covered so far can be extended with custom components. It is important to understand how this all works, what the capabilities are, and where your hooks are to develop most efficiently. But for the developers who are interested in building complete business solutions on SharePoint, you have to have an open mind. Even if you are working in Visual Studio, you will author many of your customizations in the web and Designer before importing them into your project. You will play a sort of dual role as a power user and developer, but that comes with the greatest combination of capabilities.

Advertisements

Configuring SSL in SharePoint 2010 development environment

Once in a while, when working with SharePoint solutions you need to test them on sites using SSL just to be sure that everything is working as intended.
Page Content

2011-11-10-ConfigureSSLSP2010-15.jpg

Once in a while, when working with SharePoint solutions you need to test them on sites using SSL just to be sure that everything is working as intended. Although I have previously wrote about how to configure SSL for SharePoint development environments, SSL configuration in IIS7 has changed slightly. Find out how to configure SSL on SharePoint 2010 development environments.

When working with SSL in development environments there are two scenarios: you are either creating a new Web Application and would like to make it work with SSL from the very first day or you already have a working Web Application and would like to make it work with SSL as well. Because those scenarios are not that different we will focus on the first one which should provide you with sufficient information should you need to add support for SSL to an existing Web Application.

Configuring SSL for a new Web Application

Let’s start off with creating a new Web Application.

For the purpose of this article I will be using the secure.mavention.local host header which I already added to the HOSTS file on my development machine mapped to the 127.0.0.1 IP address.

2011-11-10-ConfigureSSLSP2010-01.jpg

The most important things that you should keep in mind, while creating a new secure Web Application, is to set the port to 443 (1) and in the Security Configuration section set the Use Secure Sockets Layer (SSL) option to Yes.

Next, to be able to confirm that everything is working correctly, let’s create a Site Collection. You could create a Site Collection using a specific Site Definition/Web Template but for the purpose of simply confirming that we have configured SSL correctly, using the Blank Site Site Definition is sufficient.

2011-11-10-ConfigureSSLSP2010-02.jpg

If you choose to navigate to the newly created Site Collection at this moment all you will see is an error message similar to the following:

2011-11-10-ConfigureSSLSP2010-03.jpg

The reason for this error is that, although we have chosen to have a secure site, we haven’t attached any SSL certificate to the IIS Web Site hosting our Web Application.

Creating Self-Signed Certificate in IIS7

To configure an SSL certificate with our Web Application let’s navigate to the IIS Manager.

For the purpose of this article we will use a self signed certificate. If you have a valid SSL certificate you can use it instead by importing it to IIS on your development machine.

In the Connections list select your local IIS server (1). Then from the IIS section select the Server Certificates option (2).

2011-11-10-ConfigureSSLSP2010-04.jpg

Next, from the Actions toolpane choose the Create Self-Signed Certificate… option.

2011-11-10-ConfigureSSLSP2010-05.jpg

Enter secure.mavention.local as the friendly name of the certificate and confirm the creation process by clicking the OK button.

2011-11-10-ConfigureSSLSP2010-06.jpg

The next step is to associate the newly created Self-Signed certificate with our Web Application.

Associating SSL certificate with secure Web Application

Although IIS Manager allows you to configure a variety of settings for your Web Sites, one thing it doesn’t support is configuring a secure binding based on hostname. As soon as you select an SSL certificate to associate with a binding (1), IIS Manager will clear the existing host header (2).

2011-11-10-ConfigureSSLSP2010-07.jpg

If you would confirm your changes you would end up with a broken Web Application. Without the host header you would end up landing on the default site instead of our secure Web Application.

You can associate your Self-Signed certificate with your Web Application in two ways.

Using the AppCmd Command Line tool to associate an SSL certificate with an IIS Web Site

One way of associating an SSL certificate with a website is to use the appcmd Command Line tool to set the hostname to an existing secure binding.

First, in IIS Manager, from the list of available Web Sites select your secure Web Site. Then, from the Actions toolpane select the Bindings… option.

2011-11-10-ConfigureSSLSP2010-08.jpg

In the Bindings settings select your SSL certificate (1). Note that IIS Manager will remove the previously set host name for your Web Site (2).

2011-11-10-ConfigureSSLSP2010-09.jpg

Confirm changes by clicking the OK button.

Next, open the Command Prompt as Administrator, change the directory to C:\Windows\System32\inetsrv and type the following command:

1 appcmd set site /site.name:"SharePoint - secure.mavention.local443" /bindings.[protocol=

Executing this command will add the host name to the existing secure binding for your Web Site. If you navigate back to IIS Manager you should see the host name set on the secure binding.

2011-11-10-ConfigureSSLSP2010-10.jpg

And if you edit the binding you should see that the SSL is correctly associated as we did in the previous step.

Note that, although the host name is correctly configured, IIS Manager doesn’t display it in the Edit Binding window.

Although this approach is rather easy to follow it has a flaw as it allows you to use only one SSL certificate for all Web Sites. If you want to use your development environment for working with multiple secure Web Applications, each using a different SSL certificate you should take a look at the next approach.

Binding SSL certificate by using different IP addresses

Another way of binding SSL certificates to Web Sites in IIS is to use a different IP address for every Web Site. The great advantage of this approach is that it can be fully managed through UI and allows you to use different certificates.

The first thing that you have to do is to add another IP address to your network adapter. You can do this in the Advanced TCP/IP Settings of your Network Adapter.

2011-11-10-ConfigureSSLSP2010-11.jpg

Next, you have to change the binding between the host header and the IP address. As I mentioned before, for the purpose of this article I added an entry to the HOSTS file on my machine. To support this approach I have changed the IP address from 127.0.0.1 to 192.168.1.222 which is the new IP address I added to my network adapter.

2011-11-10-ConfigureSSLSP2010-12.jpg

The last step is to modify the binding of your Web Site in IIS. For this open the IIS Manager, from the list of available Web Sites choose the one that hosts your Web Application and from the Actions toolpane choose the Bindings option. In the Site Bindings window select the secure binding and click the Edit… button. In the IP address field type 192.168.1.222 and select the SSL certificate that you want to use. Confirm the changes by clicking the OK button.

2011-11-10-ConfigureSSLSP2010-13.jpg

When you navigate to the website now you should see the warning about the untrusted certificate and if you ignore it, you should see the Site Collection that you created initially.

2011-11-10-ConfigureSSLSP2010-14.jpg