Tuesday, September 4, 2012

Add a web part to NewForm.aspx or EditFrom.aspx

There are times when you may want to add a webpart to the new item form or the edit item form of a list.  Sometimes it may be to add code that will interact with the form or to simply add a message at the top of yoru form.  Whatever the reason, it isn't obvious how to do it.  
So go to your site and replace everything after the below depending on which form with: 
&PageView=Shared&ToolPaneView=2
EditForm.aspx
http://mycompany.com/MyCollection/MySite/Lists/MyList/EditForm.aspx?ID=213
NewForm.aspx
http://mycompany.com/MyCollection/MySite/Lists/MyList/NewForm.aspx?
DispForm.aspx
http://mycompany.com/MyCollection/MySite/Lists/MyList/DispForm.aspx?ID=213

Friday, August 24, 2012

Left align a number, currency, or percentage column in a SharePoint list.

Sometimes when you're being finicky about how a list appears on SharePoint you might find that you don't like the way it looks when number-type fields are right aligned by default.  This is generally how the fields would look in Excel but that isn't always the best way to display them.

One simple way to fix this is to create a calculated column based on the original column that you'll use in your view.
If you create a calculated column and select "single line of text" as the data format you'll have a left aligned field.  There are a couple things you'll want to keep in mind when using this method.  If there are blanks in your source field the calculated column will show these as a zero.  To avoid this you can change your calculated field to this.
=IF([Source Column]<>"",[Source Column],"")
This will have any blanks appear as blanks, not zeros.

If you're trying to left align a currency field you'll need to add code add the dollar sign back in.
=IF([Source Column]<>"","$" & [Source Column],"")
Percentage is not so straight forward since 23% will be displayed as 0.23 using this method.   If we multiply the number by 100 and attach a percentage symbol we should have a left aligned percentage.
=IF([Source Column]<>"",[Source Column]*100&"%","")

Thursday, August 23, 2012

Common formulas for calculated fields

I'm linking to a Microsoft site which gives commonly used formulas for SharePoint calculated fields.  Which I recently used to subtract months from a date.  I started by simply subtracting a rough number of days from my date field but that isn't exactly the same as subtracting months since months have different numbers of days.  So instead of using
=IF([Go Live]<>"",[Go Live]-243,"")
I used
=IF([Go Live]<>"",DATE(YEAR([Go Live]),MONTH([Go Live])-8,DAY([Go Live])),"")
Which nicely subtracted 8 months from the field regardless of what the date was.  This same concept can be used to add/subtract years and/or days.  Here's the complete list of Examples of common formulas.

Wednesday, August 22, 2012

How to word wrap the column headers in a SharePoint List

I always get asked how to save space in a SharePoint list where the data in a column is much smaller than the name of the column.  Until I found this I would abbreviate the column to the point where you'd need a key in order to figure out what it meant.

Add a content editor web part to your page that includes the code.

<style type= "text/css">
.ms-vh, .ms-vh2-nograd, .ms-vh2, .ms-vb
{white-space: normal}
</style>
Hide that content editor web part and voila, you've saved a bunch of room with very little effort.  

Thanks to Pentalogic for the original article.