Wednesday, December 3, 2008

Customizing the Sharepoint List New Item and Edit Item Screens

Customizing the Sharepoint List New Item and Edit Item Screens

A quick look at how to hide fields (example: field for the default Title column inserted in lists by default that doesn’t always prove useful for the list.).

Here we’ve started with a new Vacation Calendar List to track when people will be in and out of the office for various reasons. This can also be useful as an approval mechanism with some simple workflows attached, but that’s another topic.


The first thing you’ll notice is that the item in the list has no title, but we don’t really need one for this list. We want to track a number of things but we don’t need a freeform text box for any of them. What we want to track:

1. Start Date of Vacation (Date Field)
2. End Date of Vacation (Date Field)
3. Employee Name (Person Field, Validated against company directory)
4. Reason for Time Off (Drop Down Selection)

We can easily remove the Title column from our view by selecting the View drop down and choosing Modify this View:


This opens the Edit View screen where you can select the checkboxes to display or not display an item. Here we can chose to remove the Title column from our All Items View.


Next click the OK button to return to the All Items view and the Title Column is gone. I also added the Edit Item column as the first item in this view so we have a way to edit items in the list since the Title column was our default link to the Edit Item screen.



This is all great. However, when users add a new item to the list they are still prompted to input a Title. It is also present on the Edit Items screen. Ideally we would like to hide this column and its corresponding fields completely.



To fix this we need to go to the Advanced Settings screen under List Settings.






Select Allow Management of Content Types and click the OK button.



Now when you return to the Settings screen you will see a new section called Content Types. We want to click on the Item link.


Then click the Title link on the List Content Type Screen.



Finally select the radio button for Hidden (Will not appear in forms) and then click the OK button.



Now when you return to the New and Edit Screens the column will no longer be visible. You will also want to verify that Title is not required to have content. If you want to avoid the display of (No Title) on the Edit screen and any workflow emails then you can simply specify a default value of something like “Vacation List Entry.” These can both be done through the normal List Settings screen.

Technorati Tags: , , ,

34 comments:

Adam Lowe said...

So someone who feels extra cool about going into Designer and changing things for any excuse they can find, even if it breaks other functionality took offense to my posting this as an alternate solution on their blog and deleted my comment. Then sent me an egotistical email explaining why they were cooler.

The bottom line is don't break Sharepoint just so you can say you did custom development. If you want to hide/expose certain fields on these pages then either show or hide them. Then restrict who can edit afterwards through permissions, use workflow notifications, and or version control to moderate the data.

This is how Sharepoint was designed to deal with these problems. If you don't like it choose another platform. But don't implement a solution that is contrary to the architecture of the platform and that breaks other functionality just so you can feel cool.

Anonymous said...

great post, and great comment. I am an systems architecture and know exactly what you speak of! This is the proper way to handle this type of customization.

Anonymous said...

Adam, I agree. Where I work, if you use SharePoint Designer to alter your site, you no longer have support through regular channels.

Anonymous said...

Thanks Adam, that was very helpful. I hated the "(no title) New!" on every line after I imported a spreadsheet. - Tom

Michael Boggs said...

This is fantastic. thank you.

Daniel A. Galant said...

Sorry you felt that way Adam. I certainly don't think I'm more cool than you, nor am I egotistical. The results that we are accomplishing with our methods of modification are for different effects. The solution I map out was in response to folks who needed a way to show certain fields for some people while hiding them from others. If I offended you, I apologize.

Adam Lowe said...

Daniel I appreciate your response this time and you reposting my comment. Previously you removed my comment and sent me a terse email stating that the alternate solution I posted for a select set of scenarios was not valid for the problem you presented. I never stated that my solution was a direct replacement for the solution you put forward. I only stated that it was an alternative for some people that were arriving at your post that would have a lower level of peripheral impacts.

Anonymous said...

I'll take the gentleman's advise. I'll use another platform. SharePoint is quite a tool.. quite a tool.. falls in the realm of POS.

Bob Manjoney said...

Useful tip for hiding the Title, thanks. In an Event, I would like to be able to also hide the "All Day Event" and "Recurrence" options from the form, but these partiuclar columns cannot be marked as hidden in the Event content type - what is up with that? Anyone know a similar workaround that doesn't involve dealing with the "custom edit form" debacle in SPD?

Adam Lowe said...

Bob, the only way I know of to accomplish that without using the hide and replace trick in Designer and without causing your self a lot of headache is to create a custom list with the calendar columns/fields. You will be able to hide any of the fields or just not include the fields in your list. Then create a calendar view and set that as default. Then save it as a template if you need to use it across multiple sites.

Anonymous said...

Thanks for the comments Adam - I personally find that very useful as I have 4 calculated columns that I don't want ANYONE touching. Sometimes customization is needed, but if you can avoid it, even better for future upgrades.

Anonymous said...

Hi Adam,

My problem is I am using a project budget teamsite. When you browse project task new items I need to add a new row/column to this view. When I followed the steps in Daniel's blong did not work, and I had to reset the site. My question is in MOSS under list and libraries you can add a column is any way that we add that column to the task view new item through MOSS???
Thanks

Elizabeth

Adam Lowe said...

Elizabeth following the steps outlined in this post should work for you. Just follow the instructions to "Allow management of content types" and then create your column. Or if it is an existing column type you can just "Add From Existing." Then in order to have it appear in your views you will need to go into "List Settings" and click on the views that you would like it to appear it in, then on the edit view screen make sure the "Display" checkbox is selected for your new item. You can also you the "Position from Left" combo box to order the items for each view.

umair hassan said...

Thnx a lot it really useful for me

Anonymous said...

Nice native customization.
I'm facing the same kind of issue and I'd need something more, maybe you can help. Hiding fields not being a problem anymore, I'd like to know if it is possible to natively input some of the fields onload (not static default value) via session or url parameters, or maybe another simple way.
Cheers.

Adam Lowe said...

Re: Anonymous

You can populate the values on load through calculated columns depending on what you want to put in them. Here is an intro http://blogs.msdn.com/sharepointdesigner/archive/2008/08/01/date-functions-in-calculated-fields.aspx

Anonymous said...

Re: Re: Anonymous

Thank you Adam. Although it didn't solve my particular problem (my bad, I didn't put it simply) you provided me with leads for other problems I've faced, I'm facing and I'm sure will face.

I was eager to know if it's natively possible in WSS to pre-fill a native form with dynamically parametered data (like in PHP with variables jumping to the next page), contrarilly to the static default value we can set in SP (but the result is the same from a user point of view). Retrospectively it seems to be quite off-topic so I won't ask any further details here.

Cheers.

Nonoxp

Adam Lowe said...

No worries. Glad to help with the other issues. You can accomplish this in sharepoint through Designer or Visual Studio but that's a much more advanced topic that I'm not up for covering at the moment. I would suggest checking in with Andrew Connell's blog (www.andrewconnell.com) He would be a much stronger resource in that realm.

paisleygo said...

I am not sure if this help Nonoxp - But you might be able to accomplish what you are after using multiple content types on the list.

I wanted to have my doc lib to have catagories and topics but have the topics change according to which cat was chosen

- create a masterdoc content type -that has name title (and other fields common to all categories)

BUT instead of a field called category - I created content types for each of the categories
AND then a separate topic field for each content type (category)

- create child content types (childdoc1) that has an additional field called cat1topics and offers items related to the first category and then another child ct (childdoc2) that has a field cat2topics

- then add both childdoc1 and childdoc2 to a doclib as the content types allowed - and when you go to edit the properties - the editform will display content type- and then after you pick one it rerenders the form with the correct fields for that content type

Anonymous said...

Thank you so much, Adam. I am designing a form for onboarding and offboarding and it was driving me NUTS to not be able to turn off the title field. this is just what I needed.

Anonymous said...

how could I keep the label and just disable the enter field?

Adam Lowe said...

Sorry Anonymous. Don't know anyway to let you do that through the gui interface without getting into leveraging Sharepoint Designer. Even then I don't know a great, clean solution.

Paul said...

I'm building a suite of forms using various content types in the same list. The problem is that I can't find a way to remove the Content Type field from the edit item view. This out-of-the-box behaviour is a little counterintuitive as I would be happy if users could change the content type in the new edit item view, but there isn't any circumstance where the content type would change after the item is initially created.

Do you know of a way I can do this without having to deal with code or designer if I can avoid it?

Paul

Adam Lowe said...

This seems to be a more and more common response to the questions I'm getting but unfortunately I don't know of a way to accomplish that without getting into Designer. I will say that I don't work with Sharepoint day in and day out any more so don't let me be the definitive end to your search but it sounds like you're pushing the outter limits of what you can do with the gui interface.

Paul said...

Thanks anyway Adam. If I find a simple way to do it, I'll let you know.

Anonymous said...

First I am new to sharepoint and learning alot, but I have created a list to track improvement projects as well as safety issues. How I can I keep employees from deleting other employee's entries when they view the responses? It is the "Delete Item" tab once the entry is opened. Thanks.

Adam Lowe said...

Anonymous, I know this can be done through the GUI but I'm too far gone from my Sharepoint days to remember where. Hopefully someone else will see this and be able to respond.

Anonymous said...

Hi Adam, This is a great post. I have a request to show the Item ID when a list item is created. I tryed your solution above but I don't see the ID field. Is it possible to show the Item ID without using SharePoint Designer?

Thanks,
Vonnie

Adam Lowe said...

Vonnie I think that its possible but I'm out of the Sharepoint world these days unfortunately and don't remember how you would accomplish that.

Anonymous said...

Thanks Adam, Maybe there is someone else out there that can help me.

Vonnie

Jacob Holm Laursen said...

@Adam: come back to the SharePoint-world :-)

@Vonnie: Perhaps this link will help you: http://geekswithblogs.net/hinshelm/archive/2008/01/11/unique-id-in-sharepoint-list.aspx

Paul said...

This is great I was having a hell of a time trying to get this working with a Microsoft IT Team Workspace template. I was using SharePoint Designer and trying to add a custom SharePoint list which broke attachments and even saving new records. This does the trick! Just remember to turn off the content mode after your done making your changes because if you dont your New menu option will disappear.

Anonymous said...

Hi

This was good way to show/hide columns while adding a new item. However i have a situation where i want the column "driver's name" to remain hidden while adding a new item & if the column "is you car chauffer driven" value is yes , the column "driver's name" should show up.

Can anybody suggest how to do that ...that will be really helpful.

Rachael said...

This post is absolutely fantastic! I cannot believe it was this simple! Trying to modify the newform.aspx page is a nightmare. But this took 1minute! Thank you so much.

Post a Comment

Constructive and informative comments are appreciated. They are also moderated. I review them as quickly as I can.