..:: I like SharePoint ::.. Rotating Header Image

SharePoint Listen

How can i make attachments working in custom SharePoint listform?

If you use an application page as listform you’ll might notice that the button in the ribbon to attach files to the listitem does not work. It throws javascript errors like listform was customized… or something like id attachmentpart is missing or anything else. It might be that it displays nothing. So i thought – what a awesome story for 2014.

As i started my post serie about custom listforms i only thought about writing maybe 2 or 3 posts. This one will be my fifth post about custom listforms using visual studio and the application page way. Maybe i should make a post about the different ways to customize those forms.

But as short introduction let me give you the links to my previous posts:

Part 1: Setting up a solution with a list definition, a list instance and deploy it.

Part 2: Creating a custom list form and connect it with the list definition.

Part 3: Necessary settings for custom listform in Visual Studio

Part 4: Override Save Button in listform

Well, in order to make attachments working in your custom application page respective the listform page we’ll need to add certain parts with special id’s. Let’s see what parts we need.

Important notice: This has only relevance if you customizing also the fields. Means that you don’t use the webpartzone. To make it more clear: If you make the following part hidden or comment it out

<WebPartPages:WebPartZone runat=”server” FrameType=”None” ID=”Main” Title=”loc:Main” ><ZoneTemplate></ZoneTemplate> </WebPartPages:WebPartZone>

Then you have to manage that the attachments working. Let me show you how to do that.

(more…)

Did you know that you can remove buttons from SharePoint ribbon in code?

I am not sure if this behaviour is normal. I guess i have to investigate it another time. If you develop a listform using Visual Studio and based on an application page like i wrote in some other posts about it, you might notice, that in the edit and new form the save and cancel button does not work. They just do not firing the event.

The solution to this is really easy. In the schema file or by using code you change the listform url and also make the setting “UseLegacyForm” to true.



<form Type="NewForm" Url="NewForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\List1\NewSP.aspx" UseLegacyForm="TRUE" WebPartZoneID="Main"></form>


Doing so makes the save and cancel button working again, but now you have another stupid behaviour. Look at the screen: It is a generic / custom list as template, but it also shows buttons for edit series, claim release, distribution approval. What the hell is going on here?

ribbon2

(more…)

Do you want to have the link menu and link to item at a different column in SharePoint?

Short Info: If you like to use a different column as LinkToItem or ListItemMenu (like the Title column) and you wanna configure it in your visual studio solution in the schema.xml i would like to give you the important hint to achieve this.

In the view there are viewfields. This Fieldref need the attributes and should look like this:

<FieldRef Name=”MyDifferentColumn” ListItemMenu=”TRUE” linkToItem=”true”></FieldRef>

Important note: the linkToItem is case sensitive. It starts with a small “l” – If not i won’t work!

..:: I LIKE SHAREPOINT ::..

SharePoint Override save button in list form by using csharp

Well i a custom list form you always have a cancel and a save button. I already posted how to create & deploy custom list forms. But i didn’t mentioned that it is possible to override the save handler. That’s pretty useful if you want to do some extra action after the user clicks on the save button, or if you need to write some data of the form to an external system.

Well my other post are here:

Part 1: Setting up a solution with a list definition, a list instance and deploy it.

Part 2: Creating a custom list form and connect it with the list definition.

Part 3: Necessary settings for custom listform in Visual Studio

Cause i didn’t told you how to overwrite the save button in order to do some custom actions on this part i’ll do it now. It’s really simple. See the code below:



//ASPX PAGE

//In your aspx page a control like this should be available

<sharepoint:savebutton   runat="server" ControlMode="New"  ID="savebutton" ></sharepoint:savebutton>

//CODE BEHIND

//Override Save Button in the init method
protected override void OnInit(EventArgs e)
{

//In the init method you overrite the event handler for saving with your save button action
base.OnInit(e);
SPContext.Current.FormContext.OnSaveHandler += new EventHandler(mySaveHandler);

}

//My Save Button Function
protected void mySaveHandler(object sender, EventArgs e)
{

//you can validate the page if you like
Page.Validate();
if (Page.IsValid)
{
//Do whatever you wanna do
SPListItem currentItem = SPContext.Current.ListItem;

...
}
}


That’s it. Really easy right?

..:: I LIKE SHAREPOINT ::..

SharePoint 2013 Using linked data sources for listview

SharePoint Designer offers the possibility to create datasource which can be linked in order to display a merged or combined view of the data sources. It’s a pretty cool function in order to create list views – but it was more comfortable with the SharePoint Designer with Preview. Anyway, this post covers a small example of those linked data source.

So in this post i want to give an example of how to deal with that. In creation time, we will come a point where the following question has to be answered that’s why i put it first;

Merge or Join?

Using linked data sources gives you two options: Merging or joining. But what is the difference? You should read this great post.

A merge is an interesting thing if your data sources have exactly the same columns – so you can sort, order or group on the data.

A join is useful if your lists or data sources are completely different but they have one column to combine (like Product ID) at least.

Well, after that let’s do some work. Let’s think about an easy scenario. Ok, we have two tasks lists. We want to see all tasks from both lists. (more…)