Wednesday, June 18, 2008

How to show file extensions in a SharePoint document library

There are actually 2 ways to show file extensions in a SharePoint document library:

1. Convert the document library listviewwebpart to a XSLT dataview - Open the documentlibrary with FrontPage, rightclick and convert to dataview. Modify the XSLT to add

2. Modify the display pattern in ONET.XML - add <HTML><![CDATA[.]]></HTML><Field HTMLEncode="FALSE" Name="File_x0020_Type"/> before <HTML><![CDATA[</A>]]></HTML><IfNew Name="Created_x0020_Date"> . After making a change to ONET.XML you have to do IISRESET

Monday, June 16, 2008

Adding webparts to other SharePoint pages than homepage and webpart page

Recently I wanted to add some text descriptions to the "NewForm.aspx" and "EditForm.aspx".
All you need to add to the page are the

?PageView=Shared&ToolPaneView=2

parameters.


This opens the Task pane for adding webparts. So now you can add any webpart to the page.

Sunday, June 15, 2008

Adding Data from one list column to another list column using workflows

I got a task i.e i want to get data from one list column to another list, i want to show that data in choice field of that at the time of adding new item .

Here I am having data in list named “city” . it is having two fields “ cityname” and “statename” .

I am having one more list i.e “ cityname” .
I am created two columns “citynames “ and “ statename” with choicefileds . I want to get data of “cityname “column in the first list “ city “ to the column “ citynames” to the second list “ cityname” and to get data of “statename “column in the firstlist “ city “ to the column “ statename” to the list “ cityname” when ever an item created in secondlist “ cityname” like below screen




So for getting data just I have written vb.code as below .
Dim spsite As SPSite = New SPSite("http://pc00026:1364/test1")
Dim spweb As SPWeb = spsite.OpenWeb()
spweb.AllowUnsafeUpdates = True

Dim splists As SPListCollection = spweb.Lists
Dim splist As SPList = splists("city")

Dim states As New ArrayList
Dim citys As New ArrayList

Dim items As SPListItemCollection = splist.Items
Dim item As SPListItem

For Each item In items

If Not states.Contains(item("statename")) Then
states.Add(item("statename"))
End If
citys.Add(item("cityname"))

Next

Dim stalist As SPList = splists("cityname")

Dim regionField As SPFieldChoice = stalist.Fields("statename")
Dim cityregionField As SPFieldChoice = stalist.Fields("citynames")

For i As Integer = 0 To states.Count - 1
If Not regionField.Choices.Contains(states(i)) Then
regionField.Choices.Add(states(i))
End If
Next
regionField.DefaultValue = "Select"
regionField.Update()

For j As Integer = 0 To citys.Count - 1
If Not cityregionField.Choices.Contains(citys(j)) Then
cityregionField.Choices.Add(citys(j))
End If
Next
cityregionField.DefaultValue = "Select"
cityregionField.Update()



up to this it is working fine … but if we add new item in first list “city” i.e data does not reflects in second list drop downs . for that when ever we add item in the first list , I run a workflow , this workflow updates the data in dropdowns of second list i.e “ citynames” .

for developing workflow I used visual studio 2008 . in that I have taken sequential workflow template.
And I named that project as” getingdataindropdown1”


And pass the URL where u want to create workflow .and click next


Next select library or list where u want to deploy u r workflow i.e in my application it is “city” .and click next .



Check “ when an item is created “ checkbox . and finsh



In the design i.e “workflow1.vb(design) ” . drop “code” control from the Toolbox .



Double click on the codeactivity1 and write code as below .
Private Sub codeActivity1_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Dim context As SPContext
Dim spsite As SPSite = New SPSite("http://pc00026:1364/test1")
Dim spweb As SPWeb = spsite.OpenWeb()
spweb.AllowUnsafeUpdates = True

Dim splists As SPListCollection = spweb.Lists
Dim splist As SPList = splists("city")

Dim states As New ArrayList
Dim citys As New ArrayList

Dim items As SPListItemCollection = splist.Items
Dim item As SPListItem

For Each item In items

If Not states.Contains(item("statename")) Then
states.Add(item("statename"))
End If
citys.Add(item("cityname"))

Next

Dim stalist As SPList = splists("cityname")

Dim regionField As SPFieldChoice = stalist.Fields("statename")
Dim cityregionField As SPFieldChoice = stalist.Fields("citynames")

For i As Integer = 0 To states.Count - 1
If Not regionField.Choices.Contains(states(i)) Then
regionField.Choices.Add(states(i))
End If
Next
regionField.DefaultValue = "Select"
regionField.Update()

For j As Integer = 0 To citys.Count - 1
If Not cityregionField.Choices.Contains(citys(j)) Then
cityregionField.Choices.Add(citys(j))
End If
Next
cityregionField.DefaultValue = "Select"
cityregionField.Update()

End Sub.

AND DEPLOY THE SOLUTION .
You will find u r workflow in workflow settings of your list i.e “ city”




This workflow runs when an item is created and updates the newly added item data to the list “cityname”



Tuesday, June 10, 2008

Add your own icons to SharePoint lists (such as pdf, exe, etc.).

Put the image in:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES
Edit this file:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\DOCICON.XML
Map the file type to an icon:


Icons :






Sunday, June 8, 2008

Multiple databases for 1 Web Application

Sometimes I get the impression that a lot of people think you can only have 1 database for every Web Application. Well a lot of people (actually all of them that think that way) couldn't be more wrong than that. In the category people who do know this fact, most of them don't know how to control where to put Site Collections. Well, this post is all about that.
In your database you can place multiple Site Collections. So for your database a Site Collection is seen as "one item" (hence the Site Collection List in "Central Administration > Application Management"). This means you can make multiple databases, with one Site Collection in every database.Why is this so interesting, well for example:
Performance
Backup / Recovery
Copying data to another farm (let's say to the staging environment)
How do you do it?
Well, when a Site Collection is created, MOSS Searches for the first available database.When is a database available? A database is available when it's status is "Online".You can change this status when going to "Central Administration > Application Management > Content Databases" and then clicking on the database of your choice.AND HERE is the misunderstanding: When you set the status to "Offline" it does NOT mean the database is unavailable. It ONLY means than you cannot create new Site Collections (aka Top Level Sites).
So if you want to create a new database for 1 specific Site Collection, do this:
Create a new content database
Set the other databases all to status "Offline"
Create your Site Collection (It will be put automatically in your fresh made database)
Set that database to status "Offline" (This prevents other Site Collections to be made in this database)
Don't forget after doing this, that you at least have to set one database back online. Otherwise it won't be possible for new users to create their MySite. Since every Mysite is a Site Collection.
Today I installed a MOSS 2007 Farm for a customer and at the end we had 4 content databases. Three of them have now the status "Offline" and each has 1 Site Collection. The forth is reserved for the MySites and thus has status "Online"
Keep on doing
katuri