Archive for the ‘Sharepoint’ Category

Multiple Sharepoint Custom EditForms for a list (or ‘where to put the button’)

March 19, 2010

Yesterday, I spend a couple of hours searching the web for a solution to a rather small problem…

I’ve got a list in of our Sharepoint sites that has quite a lot of columns (49 to be exact). The list is mainly maintained by the secretaries of our CIO but we’ve got a couple of IT Projectmanagers that also need to change list items frequently (actually once a month).

Anyway, the projectmanagers don’t want to see all these fields that they may not edit anyway (this is the realm of the secretaries) so I thought “well let’s just make one editform for the PMs with only the 5 fields that they need to care about and another one for both girls with the other 44”.

There is quite a lot of information on the web how to create custom list forms (#1 google hit: but everybody seems to be satisfied with using only one of each type (newform, editform, displayform) per list. So here I was, alone, again…..

Now if you look at the xslt of an editform which has a Save and Cancel button you will see the following code:

<input type=”button”
        onclick=”javascript: {ddwrt:GenFireServerEvent(‘__commit’)}” />

This snipped creates the Save button.

My idea here was to use the same code to create a button “Extended view” on the first editform (the one with only 5 fields)  that links to a second editform with the other 45 fields.
Great Idea!
Just create the following code inside of a <td> next to the Cancel button

<input type=”button”
       value=”Erweiterte Ansicht”
       onclick=”javascript: {ddwrt:GenFireServerEvent(concat(‘__redirect={editform.aspx?ID=’,@ID,’}’))}” />

But what happens? I get redirected to the second form alright. But not to the right item! 
The new link shows http://mysharepointfarm/sites/mysite/mylist/EditForm.aspx?List=72b09691%2D4d16%2D4b88%2Dbbbb%2D22f1946654a2 !!! No ID

What happened? I Put my Button in a xslt template that is called dvt_1.formactions. This template does not know what ID I’m talking about!
So, 2 possible resolutions…

#1 move the new button to the dvt_1.rowedit
#2 somehow make sure that the @ID can be used in the dvt_1.formactions template.

As I am not a developer, I choose resolution #1 but maybe someone can explain to me how to implement #2 (would be highly appreciated not only by me but also by the other readers of this blog, I suppose).