Thursday, 2 May 2013

How to Customize SharePoint Forms

n my previous post, I discussed various options available with developers/power-users to modify out-of-the-box SharePoint list forms, with a mix of client-side and server-side approaches. However, options available to end-users are limited very limited on UI.
In continuation of same series, I'd quickly introduce you to my preferred server-side approach which is not only a better implementation but is far usable by users of your SharePoint site, and is UI-based, without worrying about what's under the hood.
You can download provided release to readily use it against your SharePoint sites/lists. Here is an example of end result:
Modified Edit Form for Tasks List 

Form Customization Requirements

Some of the prime requirements are for custom Forms on UI are:
  1. Modify out of the box Forms - New, Edit, and Display - to selectively choose fields that are available on each form.
  2. On Edit form, from fields marked available, select some to be read-only. You want user to be able to see its value, but make it non-editable.
  3. Do not unghost out-of-the-box forms for sake of form customization.
  4. Be usable on both, Windows SharePoint Services v3.0 and SharePoint Server 2007.

Solution Approach - List Form Settings

Taking example of tips from my previous posts for using Rendering Templates to enhance default UI and controls, I've created new controls to intercept default Forms and set required form configuration on server-side before they are rendered to browser. I've also taken examples from some nice implementations on Codeplex by Bewise and DBedarf, and came up with something more usable to my preference and various enhancements.
Solution is to build a SharePoint Feature to provide a Application Page linked from List-Settings to edit the configuration of current list pertaining to various Form types. Save that configuration in RootFolder Property-Bag of current list. Override the Rendering Template for ListForm and CompositeField (FormSettings.ascx) to replace our custom controls so that we can intercept the rendering on the fly using the configuration we saved in property bag - selected by list administrator.
Following list types are enabled by Feature: Custom Lists, Announcements, Contacts, Issues, Events, Links, Tasks, and Project Tasks list.

Get Started with Form Settings

Download OfficeToolbox.SharePoint.Lists v1.0 from Codeplex or at SharePoint Toolbox at MSDN Code. Unzip the archive and run Setup.exe on your Server box where you want to install or try. Go to "Central Admin > Application Management > Manage Web Application Features" and activate the Feature.
image
Now go to your list settings of applicable lists on any site under the above web-application. Click "Form Settings".
image
From settings page, you can show/hide fields across New, Edit, and Display forms. For Edit form, you can also mark selected fields as read-only... should you want to stop your users from editing some information. You can also decide the location of field's description - next to field Label or next to control itself (default).
Form Settings
Having selected above, you get following Edit form... for example.
Modified Form
Above gives you significant control over specific fields on a form to better control the lifecycle of information of your lists, resulting in not on better quality of data (saving wrong edits) but better usability/adoption by being able to communicate that information isn't available for editing once created. (edit form: read only).

Advantages of server-side Form customizations

In my previous post in series, I suggested various approaches available to modify forms, either client-side or using SharePoint Designer. While the come with their limitations, server-side has various advantages.
  1. Power to the users, no dependency on Developers - once implemented; better usability.
  2. Server-side implementation comes with advantages of managed code, SharePoint feature (roll-back, scoping etc), central manageability etc.
  3. No unghosting of forms, just in line with SharePoint APIs.
Speaking of disadvantages and future-scope, there are present limitations that there is no scope of forms/settings for individual SharePoint groups or audience. Flexibility of conditionally marking a field editable, while read-only by default. There can be various additional possibilities for enhancements, and I'm just hoping that we see far greater possibilities with forms in SharePoint 2009!!!

Wednesday, 1 May 2013

Modify SharePoint 2010 Survey in InfoPath

1) List-Based Info-Path Form: Here you can edit the new item, view, and edit form in SharePoint 2010. This is typically activated from the ribbon by click "Edit in InfoPath". Due to all the rules and functionality surrounding the 'survey list', customing the form in InfoPath is not supported. You can confirm this by going to the survey list in SharePoint Designer 2010 and clicking the button "Design in Infopath". Therefore you can attempt to create a single level survey using a custom list instead of a survey list. You can edit the new item form using InfoPath for any format that best meets the needs of your end users.
2) Document-Based InfoPath: If a simple, single level form is not robust enough, then using a List-Basd infopath form will not work. If you need more than a change to the 'look and feel' and require robust functionality, then you can looks toward a document-based infopath form. A document-based infopath form is stored in a "Form Library". It can be based on a content type or on indepedent values. Instead of editing the look of a list form, the form library saves the infopath XML file to the library. That means you can do more with the templte of the form library. We included rules, validation, and custom C# coding in our infopath form libraries, while keeping them all "browser enabled". Browser-enabled means you don't have to open InfoPAth on the desktop to view and interact with the infopath form.
To meet you reporting requirements, all of the information would have in a survey can be uploaded to SharePoint with either method above. DBInfoPath requires specifying which values to pass into the library if you want to leveraging them in the form library. You can use excel, performancepoint, KPIs, views, filters, and sorting to give you the reports you are looking for an a quick and easy solution.

Adding a Custom Table Views to Surveys in SharePoint 2010

I recently created a client questionnaire using the SharePoint 2010 survey list. I chose a survey list is because it allowed me to easily implement branching logic. Unfortunately none of the out of the box survey views suited my needs and SharePoint does not (appear) to allow me to make custom views on a survey list (unlike all the other inbuilt lists). I needed a view that would allow me to display some of the answers (i.e. client name) from each survey entry. After doing some research I came across Nishant Rana’s Weblog which showed me how to solve the problem. It turns out that there is a backdoor way to access the “Create View” page for a survey list. Unfortunately Nishant’s method is rather technical solution which the less technically oriented may find a little difficult to follow. So here’s my take on the solution, which starts from the point where you already have set up your survey.
1. Go to your survey. The following screenshot show Default view (Overview) and
clip_image002
The All Responses view. I need at All Responses view that allows me to easily identify the questionnaire(s) for a particular customer.
clip_image004
2. In order to access the survey “Create View” Page we need to find the survey ID. The easiest way to do that is to click on the RSS feeds button clip_image006 on your browser. If you are using Firefox you can do this from the bookmarks menu -> clip_image006[1] subscribe to this page . If you are using chrome you will need to install the RSS subscription extension.
3. This will return URL something like :-
https://companyname.sharepoint.com/test/_layouts/listfeed.aspx?List=aed01d53%2De632%2D4f47%2Db88d%2D0a60fe3fdb71
to access the “NewView” page replace listfeed (highlighted in yellow) with ViewNew as follows
https:// companyname.sharepoint.com/test/_layouts/ViewType.aspx?List=aed01d53%2De632%2D4f47%2Db88d%2D0a60fe3fdb71
clip_image008
4. If you wish to create a multi-column table view us the All Resources link under “Start from an existing view”.
WARNING: If you using the “Standard View” option in the “Chose a new format” section you will end up creating an Overview View (see image below) , regardless what you enter on the new view page.
clip_image010
5. Select the columns and their display order you required. In the example below I have made this view my default view
clip_image012
6. the new custom view looks like
clip_image014

SharePoint 2010: Howto start customize list form (New/Edit/View) using InfoPath Designer 2010

English
In SharePoint 2010 there we have more option to customize list form. For instance, you can use SharePoint Designer 2010 or InfoPath Designer 2010. Since modifying list form using SPD is already exist in previous version. I will just show you how to customize list form using InfoPath Designer 2010.
When customizing list form using InfoPath Designer 2010, you will get all form designer benefit. For example, you can define the field validation rules, parent-child relation etc. And bet what, the process is straight forward. In this very basic how-to, I will demonstrate how to start customize list form using InfoPath Designer 2010. I will create an Book List with “Title” – “Author” – “Status” column. In the New form, I will only show “Title” and “Author” – while in Edit form, “Title” and “Author” will be readonly, but “Status” is editable.
How to customize list form using InfoPath Designer 2010.
  1. Prepare the custom list.

    Prepare custom “Book List” with 3 columns: “Title” – “Author” – “Status”. “Status” field is choice “Available” – “In Used” – “Missing”. After creating the list and preparing columns, we can start to use the list and add a new item in this form.
  2. Start InfoPath Designer
    Start InfoPath Designer and select to design SharePoint List form.

    Type in the SharePoint site URL

    And then select the Book List from the list of available data.

    Finally, click on Finish.
  3. When the form editor open , you can start to edit the New form. I add a title “Book List Entry” and delete the “Status” row.

    And here is the result:
  4. Add “Edit Form” view in the designer, and set Title and Author as readonly.

    Type-in the view title.

    Design the form – add “Status” column in the form.

    Set “Title” and “Author” textbox property to “ReadOnly”

  5. Publish the form to the list.
  6. Configure the “Book List” to use designated form.
    Open the list setting page, and expand context menu for the Forms.

    Since the first view will be the default – our interest is only to the “(Item) Edit Form”. Click on (Item) Edit Form link, and change the Form view.
    You will realize that now you are seeing form services in web part.

    Click on Web Parts Tools tab, and then click on Web Part Properties.

    In the Web Part Properties, select the designated view.
  7. And here we go with the custom “New Form” and “Edit Form” for the list.
    New Form.

    Edit Form.

Create a Custom View for Survey List


Software Technology Tips

 
In SharePoint, custom views are used to display the items in a list/libraries with custom look and feel.Therefore you have to choose a view format like Standard View, Calendar View, Datasheet View or Gantt View  and accordingly you can customize the display style by choosing Filter condition, Sort method, Group By condition  etc. SharePoint allows us to create custom views for the list and libraries. But for the Survey type list, SharePoint documentation doesn't mention anything about creating a custom view.
Below mentioned steps are can be adapted to create a custom view for Survey List.
Steps-:
  1. Open a SharePoint Site......Open the Survey List. 
  2. Find the ListID from the URL like
    List=%7BF2141E9F%2D8EA2%2D42EE%2DA965%2D52F1D7362066%7D
     
  3. Now change the URL in the browser as 
    http : //SiteName:PortNo/_layouts/ViewType.aspx?
  4. List=%7BF2141E9F%2D8EA2%2D42EE%2DA965%2D52F1D7362066%7D
     
  5. Then choose a view format for the survey list.
     
  6. Type a custom View Name.
     
  7. In the same page open the style tab, choose a style for this view e.g Basic Table (Don't set the style as Default).
     
  8. Then press OK to create the view.
     
Edit the Custom View
 
  1. Open the Survey List
  2. Go to Site Action....Click on Edit page....Click on Modify Shared Web Part
  3. Now click on Edit the current view
  4. It will open the view .Modify the view & save it.

SharePoint 2010 : Enforcing Unique Values and Limiting Access on Custom Lists

There is a lovely little feature in SharePoint 2010 called “enforce unique values”.  This prevents users from duplicating data.  The option is available any time you create a column.

So when you have a list of companies for example, and you try to capture a new record with an existing company name, you will be stopped.


But!  A common action in lists, is to restrict users from editing and viewing other items in that list.  You can change the settings so that they can only edit / view their own items. (Found under List Settings – Advanced Settings).

If you try and activate this restriction while you have enforce unique values activated, you will get an error message :
If you read the error, it makes sense.  What it is telling you, is that you can’t make users type unique values if they can’t see all the values available to them.
So if you want users to be restricted in what they see, you may get duplicate entries.  If you don’t want duplicate entries, then all users must be able to see all the items in the list.
What you can do though, is give everyone read rights to the complete list and edit rights on their own.  Then enforcing unique values will work just just fine.