How to Customize SharePoint Forms - Part 2

In 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!!!

That's all for now, hope you find it useful. Do send in your suggestions for improvements.

-- Sharad

Download: OfficeToolbox.SharePoint.Lists v1.0 from Codeplex.

85 Comments

  • One of the better solutions out there to acommplish this task. The only problem is that it doesn't seem to work on existing lists. For me it only works with new lists (created after the feature was installed and activated).

  • AlexO, Please note:

    "Following list types are enabled by Feature: Custom Lists, Announcements, Contacts, Issues, Events, Links, Tasks, and Project Tasks list."

    I chose to not include Document Lists for their forms integration with Office, or anything else we might end up compromizing. You can however edit Elements.xml of Feature to include your list types, and de-activate/re-activate the Feature. It should work.

    -- Sharad

  • Excellent work. A quick question, when I've used this on one of my lists it's worked great except for two columns which are both disabled under the Field Description section but both have the Label value set. However the label still appears under the control.

    Both of these fields are UserFields. Is this the problem?

  • Mark,

    Due to a minor bug, by default, on a new list the label are set under Title of field, and I have explicitly disabled changing that for UserField control. It should instead have loaded them next to Control, and will be fixed soon.

    Note: There isn't a simple way to seperate Desciption of UserField control and its fixed next to control. Hence the intent to keep it disabled - but with correct default setting, coming in next release.

    Happy that you liked it. Would like to know what else you think would be useful to control for forms?
    - Field order, per Form type.
    - Field appearance, per Audience/Role/User/Group.
    - ...?

    Thanks

  • Looking forward to the next release :)

    As for ideas for the future, of the top of my head (not sure how feasible these are), I can add;

    * Fields only visible based on Audience, Role, etc (I think this is what you refering to above).
    * Certain fields availble based upon an action defined in a QueryString, e.g. the same list can be used but based upon a QS value, only certain fields are editable/shown. Might be usful for workflow where poeple along the way are required to complete different fields and you don't want them confused by all the other fields.
    * Custom validation of fields, e.g. data validation, is this date entered after today or today + 5 days, etc

    If I think of anything else I'll be sure to let you know.

    Thanks,

    Mark

  • I would like to edit a "Project Tasks" list, which is not included.
    I took a look into the sourcecode, but I'm not very familiar with sharepoint developement and I can't seem to figure out what to edit...

  • Well looks good...
    One feature that would be nice.... Sharepoint doe not show the description of the field during display mode (they're only showed during edit) , is there a way to configure that ? Let's say that you put on the Field descrption something like a checbox "Show on Diplay Form".

    Another thing that I also miss in sharepoint is the ability to show only x charachters of the value of a Text field in the "allItems". Let's say a have a news list.. but I don't want to have an abstract field in it, yet I would like to show the first 50 characters of the news in the AllItems.
    There are plenty of Ideas right now on my mind that could be done with this toolbox!
    Good stuff!

  • sharad,
    take a bow. this tool is great. thank you!

  • nice post it helped me lot......

  • If only you could make this audience targeted, I wouldn't need to use my javascript method.

    Great work - if you nail that issue then its the perfect solution

  • Paul,

    I think that can be nailed in due time. but first I'm aiming to give custom server-side validators to be configurable on Form Settings, based on Field values and custom rules.

    That's coming...

  • Travis - did you activate the feature for the correct web app? Go back to Central Admin and check... I hadn't even seen the web app dropdown and had just activated it for the wrong web app.

    HTH,
    Gillian

  • Hi,
    thanks for this feature. Can you explain the method do you use for make an readonly input in the edit form.
    I have download the source code in codeplex, but I have not find the method in the code.
    The date of your release and the date of last source code is different in codeplex, maybe it's for this reason that I don't find the code.
    My objectif is to transform the field in read only depending on the state.

    Thanks,

    Guillaume

  • Sharad,

    Form Settings is the single most productive feature in Sharepoint. I have successfully used it in application projects and it allows me to use ootb functionality of newform.aspx,dispform.aspx and editform.aspx instead of having to develop custom forms in SPD. It works has worked flawlessly for me and is the single most important tool besides SPControl Deployment Wizard in my tool kit.

    I do have one comment about using Javascript. When Form Settings hides a field in a ootb form, the field is not rendered in the html so I can't set a default value from a query string. I still use javascript to set the value and hide the string.

    I do have some nice to haves.

    - Form Settings by Content Type. this would be nice to have but I have been able to work around this most of the time.

    - The ability to attach validation code to fields

    - What I would really like to have however is a dynamic form generator that can place fields and tags, in relative locations on the screen. based on table information on a sharepoint list. Sort of a poor mans InfoPath.

    Many Thanks for your Excellent Tool

    Charlie



  • I got the logic how you are hiding a field. But i did not find the logic to make a field read only. I really need this. Please help.

  • Today i downloaded your tool, Its helps me lot and cut down lots of development time....

    Keep it up... we are looking more stuff from you....

  • Great work, Sharad!

    One of my 2009 wishlist is the ability to hide a field based on user role/permission. (e.g., admin fields). I'm sure you've heard this before....

  • Hello everyone, greetings for new year!

    I regret for the silence in between, and many thanks to all of your feedback here and direct mails. I hadn't expected that it will be recieved this well by SharePoint community. Lot of users/developers reached to me directly, asking for enhancements.

    I've been busy lately, and haven't had chance to dust-off the code and enhance (or even share on codeplex). I hope to do that in near future, and there are two features that are on top of my mind:
    1. Form Validations... not just things like regex validation, but also validation based on related fields.
    2. Audience Targetting and/or Field Security... to limit specific fields (view/edit/create), based on who they are.

    Those of you who may have tried, would know that Form Validations is ambitious - given the limitations.

    At this time, I do not have timeline to commit to. Please come back, or subscribe through RSS.

    Cheers
    --Sharad

  • Babu,

    It seems that you need to try BDC (Business Data Catalog) connection to your SQL Table. BDC comes with MOSS Enterprise.

    -- Sharad

  • Thanks Charlie, I like the idea of Form Settings per Content-Type. I'd consider that.

    --Sharad

  • Pid, to show field description in Display mode... you have to likely override the default rendering template for Display form, just like I talked about in my previous post on Form customizations and also implemented in Form-Settings above for Edit form, where-by location of description can be modified.

    Hope it works.

    --Sharad

  • Looks great, but I am getting an error running setup. Also if I use the stsbatch file I can see the solution in Solution Management, but is does not appear in the Manage Farm Features screen. Any ideas?

  • Found the problem on the error, the zip file had a incomplete wsp.

  • Great stuff! Can you please update the source code in CodePlex to match this article and the 7/28/2008 release?

    Thanks!!

  • Hi Sharad,
    first of all ... great tool!!! Thanks a lot.
    Perhaps you can also implement some properties regarding the attachments of an item. For example hiding them or not to be able to delete them (kind of read-only) but with the possibility to add new attachments.
    Best greetings from Germany,
    Simon

  • Hi Sharad,

    Great post.
    I have the following question: I installed the Office.Toolbox and enabled the feature in Sharepoint Central Admin. All works fine. But know I am not having the "Form settings" under General Settings.

    Can a german installation of MOSS be the problem?

  • Well, that may be the case Thomas. I work with English, and haven't tested with alternate language. Also no other user - English user likely - reported such a problem.

    --Sharad

  • Thank you so much sharad you made my day

  • I would like to clarify if this only works on new forms created after this feature is installed and activated or if I am missing something.

    Thanks

  • Is it possible to include a radio button conditional statement in a form, so that if the user selects Yes, the particular field becomes mandatory otherwise becomes optional?

  • This is an awesome tool. However, it doesn't work with Wiki Libraries. I'd like to see the code extended to cover those library types as well. I'm running WSS 3.0.

    [I think I just turned into one of those whinny users who complain about a cool tool when it doesn't do what they want ;)]

  • Hi Sharad,
    I downloaded the code but i am unable to see 'OfficeToolbox.SharePoint.Lists' Feature under 'Manage Web Application Features' in Central Admin.

    Please help!!
    Thank you

  • I want to add the "Audience" field to a form, thus allowing users to choose which audience can see the post. How can I accomplish this?

  • I want to add the "Audience" field to a couple of forms (in the Employees Activities Site Template) thus allowing users to choose who can see their post. I don't think this tool will accomplish this. Can anyone help?

  • This is a great, but does not seem to work on the service requests in the Help Desk template. Is there a workaround to get it to work?

  • Hi Steve,

    Iam using custom aspx form(developed in vs.net) in content types for edit/desplay. When i edit the list item the form will open but the form fields are not getting binded.

    How to bind the form fields when a item is edited

    Thanks,
    Pravyn

  • We currently installed this and it is working great, but we have a deployment with thousands of lists and it looks as though we will have to go to each single one and enable the form settings. Is there an automated way to set every list to use these settings without touching each one?

  • David,

    This is enabled at Web-App level. Once activated, all sites (hence lists within) automatically get this. Now every list has different columns, and you have to (designers/admins of each site/list) gets to decide which columns are to be visible/hidden/read-only. I don't think its ever a case that, say, you'll hide Title column from all lists in all sites across!

    If I've misunderstood, do you mean that you'd rather want this to be available on a per list-template basis. You get to centrally decide, say, Contacts list when used in any site in a farm/web-app should have specific settings configured centrally. If that's what is wished for... it's not what it does today.

    Thanks for taking interest.
    -- Sharad

  • Hi Thomas,
    It would be interesting to know in which case you aren't able to hide a field.
    Tool exploits a property in base class at runtime, IsFieldExcluded, when iterating all fields visible to a list. There has to be a reason why that proprty is not being repected in your (templates) case.
    There may be a case of modified/unghosted forms via SPD etc. I'm simply assuming until you can give me specifics of which form/list within Helpdesk template, so I can reproduce.
    In worst case you may want to consider JavaScript approach I discussed in part - I. Also Paul Clumsee talks about the approach rather "cleverly". Checkout...
    www.cleverworkarounds.com
    --Sharad

  • I have installed and activated the feature in central administrator, but i cant see "Form settings" in list settings, for any list.

  • Is it possible to increase the height of the textarea - labelled 'Description' in your screen shots? I migrated a list from WSS 2.0 to WSS 3.0 and the textarea is much shorter in WSS 3.0. Naturally, my users are unhappy about this!

  • hi
    nice article but my situation is slightly different, i want to how and hide fields depending upon the user groups, means if a user is part of Group A, he can view some fields, but another user with Group B should not be able to see those fields.

  • Incredible! Iam using it on my production box, works like magic....Simple thigs MS ignored, great job sharad.

  • Hi Sharad,

    I've downloaded the tool, it's great!.
    It helped me to develop my sites better than before!

    Regards

  • Hi,

    When I tried to run the installer it told me it could not find the specified solution file "OfficeToolbox.SharePoint.Lists.wsp". Where can I get that from?

  • I am having the same problem as Jeanese Carriere. I can't get it to work on the service requests list in the Help Desk template. Please help this has been driving me crazy.

  • Great product...nice work! I have one issue similiar to what others have spoke of. After install, it appears that any list type this applies to, all decriptions disappear. From what I can tell the issue is because when installed, and it gets applied to existing lists, the Field Description is set to Label by default. Since label isn't really an out of box option, could this be changed to default to Control instead? I believe this would resolve the disappearing discriptions on install.

  • For those who activated the feature and were not able to view the "Form settings" in list, (i had the same issue)it is because i had activated it for the wrong Web Application :) so in the central administration -> Manage Web Application Features -> Change the Web Application (top right box) to the one you are currently using

  • I can confirm it works in a Spanish SharePoint installation. Simply a very good tool!

  • This tool is great, but it does not work on the Service Request list in the HelpDesk Template. Several of us have asked about this issue and would deeply appreciate your resolution to this problem. Do we need to add the list type ID to the Element.xml file? If so, do you know what the ID for these lists are?

  • this tool works great if you're using the standard forms, however if you use custom list form, since they do not implement the ListIterator. is there any way to get this to work with the formfield controls instead of the listiterator?

  • so if you dont admin access to the server but are a site admin how do you do this? for now I'm putting some javascript that does the following:

    ocontrol = findacontrol(sField);
    ocontrol.parentNode.parentNode.style.display="none";

    is there a more elegant way to do this?

  • I created a new site and added a list and the Form Settings link is not listed under General Settings. It is listed for the sites that had been created before I intalled and activated the feature. I tried deactivating and reactivating the feature but no luck. Do I need to reinstall to pick up the new site?

  • Thanks for the feature. It works great and is very useful.

  • I was looking for a way to control the visibility of fields based on the value of another one. Essentially, I need to accomplish branching behavior. Since you can't launch a workflow from a survey, I was hoping someone might know an alternate method?

  • Great job w/the controls; however I noticed something -- I am unable to set the 'Required' flag on the form anymore so fields that require content are no longer validated.

    thnx

  • Simply fantastic :-)great post

  • What should that mistake be in the installation?
    Solution manifest for solution '195535a7-e28f-41d0-a84c-d81e45720fee' failed validation, file manifest.xml, line 2, character 110: The 'Share
    PointProductVersion' attribute is not declared.
    d:\temp\OfficeToolbox.CentralAdmin.wsp: The Solution installation failed.

  • I need to create a column type that allows rendering html code that calls java applets. I noticed that xml webpart allows the rendering of applets, but publishing columns or rich text html columns do not. How can I get xml webpart to render my column input?

  • The list id for "service requests" list in sharepoint template helpdesk is 7151.
    You also can find the elements.xml file in: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\OfficeToolbox.Lists.FormSettings

  • Hi sharad,

    Its a great tool to use,i understood the logic on how you are hiding the fields,but the logic foe making the fields read only in edit forms is not explained anywhere and the code in the codeplex is not update.
    Could you give more information on the logic on how you are making the fields readonly.

    Your response will be very appreciative.Waiting to hear from you at the earliest.

  • Hi Sharad,

    I have installed it successfully, but while trying to activate the feature on Central administration, It comes up with 403 forbidden error.

    Any Idea, why this issue? I have tried with various web applications and still cannot move further!

    Thank You

  • Hi

    I need to make a helpdesk data import form that add 1 to a ticket numder (example id number +1) so each ticket has a unique ticket nenmder, also can I make a custome inpuse data screen / list also? Can you help?

    Thanks

  • Hey Sharad, I was wondering if there was any way to do exactly what you are doing but when the item is displayed/edited. I need different user groups to see different fields based on the status of the item. So for example, First Name and Last Name can be seen/edited by Group 1 when Status is 1 but can only see/edit Last Name when status is 2. I tried using a web part on the display form and edit form and setting the ControlMode on the base field controls however I cannot save my for when editing. I can get the fields to hide dynamically when a different group edits/displays at different statuses but I cannot save my form on edit.

  • How to customize sharepoint forms part 2.. Great idea :)

  • This is great, but if you install this on your 2007 environment, how do you smoothly migrate it to 2010? Do you have an update to thi solution?
    thanks

  • vcdVm8 Hey, thanks for the post. Keep writing.

  • Find Much more Signal Viewers & Scan Tools Information regarding 2012 discover General Dash Programmer Tacho Professional '08,Top Quality Tacho Professional

  • Hey there exceptional website! Does running a blog like this require
    a large amount of work? I have very little expertise in coding however I had been hoping to start my own
    blog in the near future. Anyways, should you have any recommendations or tips for new blog
    owners please share. I understand this is
    off subject however I just needed to ask.

    Thanks!

  • Having read this I thought it was rather enlightening.
    I appreciate you taking the time and effort to put this article together.
    I once again find myself spending a lot of time both reading and posting comments.
    But so what, it was still worthwhile!

  • I always spent my half an hour to read this web site's content everyday along with a cup of coffee.

  • Thanks designed for sharing such a pleasant thinking, paragraph
    is fastidious, thats why i have read it entirely

  • Hello there! This post couldn't be written any better! Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this write-up to him. Pretty sure he will have a good read. Many thanks for sharing!

  • Can you tell us more about this? I'd care to find out some additional information.

  • Excellent blog right here! Additionally your website rather a lot up fast!
    What web host are you the use of? Can I am getting your affiliate link on your host?

    I wish my website loaded up as quickly as yours lol

  • Yes! Finally someone writes about network.

  • Hi to all, it's actually a good for me to visit this web site, it consists of helpful Information.

  • Hi there friends, how is everything, and what you wish for to say about this piece of writing, in my view its truly
    amazing in support of me.

  • Why people still use to read news papers when in this technological globe
    the whole thing is accessible on net?

  • Wonderful post! We will be linking to this great content on
    our website. Keep up the great writing.

  • My brother recommended I may like this website. He was entirely right.
    This post actually made my day. You can not consider simply how so much time
    I had spent for this information! Thanks!

  • Pretty section of content. I just stumbled upon your website and in accession capital
    to assert that I acquire in fact enjoyed account your blog
    posts. Any way I'll be subscribing to your augment and even I achievement you access consistently rapidly.

  • Touche. Sound arguments. Keep up the great work.

  • Way cool! Some extremely valid points! I appreciate you writing this
    write-up and the rest of the website is really good.

  • Thanks for sharing your thoughts. I truly appreciate your efforts and I am
    waiting for your further post thanks once again.

Comments have been disabled for this content.