How do we build custom forms in a sharepoint solution? - sharepoint

Sharepoint designer is not allowed. The forms must contain fields with references to list items but may contain custom asp controls as well, which we whish to use later in the process.
The target isn't always to replace the original new, edit and display forms but to create extra forms too. Currently, we create custom forms by copying the existing base forms and edit them by hidding the zonetemplates and add our custom fields below. It aint the most elegant way, but at the moment the best result we have so far.
I would like any suggestions.

If developer tools ar not allowed, you might want to consider Infopath.
Also, SharePoint comes with a Form Web Part that you could include in your page.

Related

SharePoint 2010 Survey View

I need to add an ability for users to add custom views for a Survey List. Using Designer is not an option.
In order to add a new View I now open the standard SharePoint form "/_layouts/ViewNew.aspx?List={SurveyListID}".
I setup a new view selecting the fields I want to see. Then, when I look at this View it looks like standard "{SurveyTitle}/overview.aspx" view no matter what I do. But I need it to look more like a SharePoint list view. I've seen dozens blog posts where people used this method and no one mentioned any problems like I am having. I've tried this method using 3 different SharePoint farms and I get the same behavior.
I was able to create a view that works OK using Designer by copying "All Responses" View and editing . However, forcing users to use Designer is not a great idea.
Does anyone know an easy method to force my custom views to display properly in Survey List?
Finally, I've found solution.
Open the page /_layouts/ViewType.aspx?List={SurveyListID}
Create a view based on "All Responses" View
Done! No need to use Designer

SharePoint 2010 site templates and list customizations

In SharePoint 2010 I have a list. I modified the default list page (allitemsg.aspx) to show another list, so now in the page I can show a manager and his sub-employees for example.
Now if I save this site as a template and create a new site based on it, this customization does not carry over. The manager list page will only show the managers, and the sub-employees list will be gone.
Is there a way to make a template the preserves this type of customization?
Thanks.
Not really a solution to this direct problem, but if you used related item views they do carry over.

is there a way to generate input fields in ascx from sharepoint 2010 list

I'm developing a custom aspx form for a SharePoint list in Visual Studio, basically to add a new item to the list (that's a business requirement).
I'm wondering if there's a way to generate input controls from the list in design time just like we used to do from a database in ASP.NET.
If you're doing a straight match from the SP List to web form take a look at the SharePoint Form Generator web part
Just add the web part to the page and identify which list to build a form for.
To answer your question, yes there is a way to generate the fields. What you are looking for is the Sharepoint FormField class in the webccontrols namespace.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.formfield.aspx
Here is an article explaining the entire field controls heirarchy for sharepoint. http://msdn.microsoft.com/en-us/library/aa543321.aspx
Generally this is used inside an ASCX control, let me know if you need any more explanation.
I discovered T4, that's exactly what I'm looking for,,, I used it to generate input controls in design time... I faced some problems accessing SharePoint from T4 templates but were resolved using The Client Object model :)

How can I effectively group a whole bunch of Sharepoint lists?

I'm still learning Sharepoint and all of its various concepts, so apologies in advance for my ignorance. Here's what's going on - my company is moving a whole bunch of forms from another application into Sharepoint as InfoPath forms. Each InfoPath form is a Sharepoint list. So, we've got something like 300 different lists representing these forms.
My task is to put these lists on a page in some kind of reasonable format, meaning we need to present them in more reasonably-sized groups. Essentially, what I think I need is a list of lists. I've seen a few discussions here on this topic, all of which end with "Sharepoint doesn't provide a list of lists you need to do it yourself". I attempted to use a Content Query web part, but that only could get me the items inside each list, which in this case isn't what I want - I want the Sharepoint list itself.
From what I've read, it sounds like some custom code can build what I want. Is there any other way for me to group these lists?
Edit for more information: Part of the problem we have is that we aren't sure how to group the lists. I believe what Tom says below, that it's pretty easy to get a list of all the lists. But somehow, we still have a need to get the lists into the appropriate buckets.
For example, let's say there are 10 lists, and we want to group them by department. The first three belong to HR, lists 4-7 belong to IT, and lists 8-10 are Executives. Even with a custom code solution, we still need to make that connection, and I'm not sure how to do that (easily). If that's going to be a manual process anyway, it seems like a master list like #strongopinions suggests will be easier than a custom code solution?
I got this working using SharePoint Designer and a DataFormWebPart.
Steps:
Open the SharePoint site by clicking File -> Open Site and entering your site's URL (Ex: http://servername/sitecollection/subsite)
Open the page you will be adding the webpart to (Ex: default.aspx)
Click in one of your web part zones
Add the DataFormWebPart by clicking Insert -> SharePoint Controls -> DataView
In the Data Source Library pane on the right, under XML Web Services, click Connect to a Web Service.
Enter in a service description location to the Lists.asmx web service (Ex: http://servername/sitecollection/subsite/_vti_bin/Lists.asmx)
Click Connect
Choose GetListCollection for the operation
Click on your newly created Lists datasource and click Show Data from the dropdown
CTRL+Click to select DefaultViewURL and Title
Click Insert Selected Fields as.. -> Multiple Item View
Save your page and you're done!
P.S. You can also use something like this to generate a nice link:
<a>
<xsl:attribute name="href">
<xsl:value-of select="#DefaultViewUrl"/>
</xsl:attribute>
<xsl:value-of select="#Title"/>
</a>
Edit
Shoot. Didn't see the SharePoint2010 tag... these are instructions for SharePoint 2007. I'll leave this answer up here in case it is helpful.
I think the most flexible solution would be to create a custom webpart. With Visual Studio 2010, creating and deploying webparts is easier than ever before and the code to list all lists isn't very difficult either.
Not that I don't like SharePoint Designer, but I don't like to call the SharePoint webservices from inside SharePoint. It doesn't sound really performant.
Let me know if you need some help with the code.
You could create a list of links in SharePoint to act as a "master list." This list would contain URLs to each of the other lists. Then display your "master list." This would have to be created by hand though. Other than that you would probably have to use custom code to generate the list.

Deploy an InfoPath form with promoted fields to SharePoint within a WSP

I've been playing around with publishing an InfoPath form to a SharePoint site as a content type to try and see what happens. It works okay in that updating a form instance in a library will update the library columns. Short of the promoted properties in InfoPath however I can't see how this mapping works.
My aim is to have a CAML defined content type as part of a WSP. The content type will install preconfigured having the promoted fields from InfoPath. There will be some additional fields not in the form but needed in the content type for the workflow that will run when these forms are filled in. Actually the extra fields in the content type arn't critical, one step at a time.
I've tried specifying the promoted fields in the form options and network publishing. Then creating a form content type by hand through the website and linking it to the uploaded form template. I would hope that when the form runs it would check the list and create the columns but it doesn't do that.
I've also tried SharePoint publishing the form as a content type, then creating my own content type that references the template URL where it was published. Creating the site columns by hand and linking them in with my content type. Whatever way I try it the InfoPath forms don't link the promoted fields to the columns I've created.
So short of publishing properly through InfoPath I can't get this mapping working myself. Really I'm trying to reproduce what the SharePoint publishing does without understanding how it maps the fields. If I can't do it through the website I'm hardly going to get it going with CAML and have this as a single installable solution where a customer would be able to activate the WSP and have the site, libraries, content types, lists, forms, workflows pre-created and all set up ready to use. I already do this with other projects just not with actual forms libraries.
Any advice would be very much appriciated.
[EDIT]
If it comes to it I might have to resort to (shudder) having some code in the form that on close would write particular fields to the list and do away with the "promoted fields" altogether in favour of my own may of doing it with which would admittedly be worse but it would work.
The column mapping is probably working on field guids rather than field names - any fields and content types you create through the browser will be assigned random ids, which obviously won't help with the mapping.
The best approach is probably to do everything manually with infopath publish, then export the forms library with solution generator. That should give you something consistent you can bring into WSPBuilder and adjust as necessary.

Resources