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

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.

Related

How can i duplicate a whole nintex form + workflow function

I just took over this entire sharepoint project over from an ex-staff and I am supposed to bring his entire nintex form over to another site. However, I do know any methods or functions to do so.
This form in particular is a nintex form, that upon submission, would consolidate all responses into a custom list which can be then be exported into excel format.
The workflow works where after each submission of the form, an email will be sent to the moderator.
I am extremely new into sharepoint and I do not know all the correct terms so please guide me well.
Good morning.
In order do do this, Nintex Workflow and Forms, both have an option of export/import, as you can see:
So, after the export you will get a file with the extension .nwp(Workflow) and .nfp(Form). Then, in the other site that you refer, you just need to create a Workflow or a Form and select import with that file.
Note: If you are new in Sharepoint/Nintex, notice that any List, Document Library, etc. where the form/workflow is associated will need to be as it is, in the old site, otherwise you'll need to make some changes to the Workflow or Form to include the new site information, such as list column names (per example).
I hope that this answer could help you, have a nice day.

How do we build custom forms in a sharepoint solution?

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.

Customizing the "Upload Document" Form in SharePoint 2010 based on Content type

When you click on the name of a library, go to the documents tab, click on "upload document".
An upload form appears that is created using the dialog framework. The 1st choice on the form is content type.
I need to instead launch a custom infopath form that will allow me to dynamically populate a 2nd dropdown box on the page after the content type (still 1st) dropdown is populated.
I feel like I'm really grasping at straws here. At this point I could use a reference to a relevant section of a book, a link to a relevant post or even just the correct terms to put into a google search. What is the correct name for that form?
I found this which seems to teach you how to insert a customized aspx form: http://microsoftsharepointandbeyond.blogspot.com/2009/10/customizing-ootb-sharepoint-forms.html
But I'd really like one that uses Infopath instead.
Any advice or direction you can provide would be greatly appreciated.
I'm pretty sure doing this with infopath is not possible, the forms are bound to a (codebehind) class in the SharePoint object model, which handles the actual upload (add to list, set field values etc. etc.).
A custom aspx page would be possible though, exactly as the post you mentioned descibes. I agree with the post's author that an HttpModule would be best, because:
editing the OOTB upload.aspx in the 14 hive would make your environment unsupported (i.e. if anything brakes, MS will have you revert your farm to a supported state before they come and help you.
The next time you install an update for sharepoint, your changes could be overwritten.

Best Practices for Content Types in SharePoint

Recently, we came across a severe problem in production farm with the Content Types. I would like to explain the background of this problem first.
We have nice working feature for Content Types installation in production and test farms. We developed and deployed (using wsps) this SharePoint feature in Visual studio. We are using the publishing pages using page layouts and Content Types to help content editors to quickly publish the web pages. Unfortunately, some Content Types and site columns have been manually updated/added by some people in the production, so whenever I (developer) make some changes to the existing Content Types (using Visual Studio and feature activation/deactivation) , SharePoint removes one or two columns (during feature activation/deactivation) from Content Types; or the columns which have not been added in a best practice way. I think the best practice is to update Content Types using Visual Studio.
Now, I wish to ensure that site columns shouldn't get removed from Content Types upon feature activation/deactivation.
Note: Our feature for Content Type activation/deactivation doesn't hold any activation dependencies in the feature.xml
Recommended Approach
Based on all these factors, my suggestion would be to:
• Create two Features: one for the original markup and one for making changes. (Or you can put them in the same Feature; I just want to differentiate between where you do what.)
• The original Feature should contain the CAML for Site Columns and Content Types. This ensures the IDs have been assigned ahead of type and remain constant.
• If you want to update a Site Column by changing nearly anything about it except its Field type, do it using a Feature Receiver. By doing this, you can call the Update method and pass in a boolean indicating if you want all the existing assets in the site that inherit from this to update to, (something you couldn't do via the CAML.)
• You can also add an existing Site Column (that you provisioned via the CAML feature) to an existing Content Type (that was provisioned via the CAML feature). This is helpful if the Column was not part of that Content Type before, etc.
• In a scenario like the one I just mentioned in the last bullet point, it's necessary to deactivate and reactive the CAML feature (to provision the new assets) before calling your Feature Receiver. What will this mean for the site? Since all the Site Columns and Content Types in the lists in the site are using the same ID's as the ones provisioned in the Site Collection root, removing its parent from the Site Collection won't change that. It might leave it orphaned temporarily, (i.e. there will be no relationship between that item and an item in the Site Collection root, but it will function the same way it always has, since it's really a fully-functioning copy of the original item) until you reactivate the Feature that puts the item back in the Site Collection. It's like the parents are going on vacation when you deactivate the Feature, and are coming back home when you activate the Feature again.
You have a choice when it comes to how you maintain the CAML and the Feature Receiver, since you have two scenarios: existing Site Collections and new ones.
• You could make a policy that every time you write code in your Feature Receiver to update a Site Column or Content Type, you have to make the change in your CAML as well. That would mean that every time you activated the CAML Feature in a "fresh" Site Collection, the CAML would be up-to-date and accurate; there would be no need to run the "updater" feature. (In your Feature Receiver, you should make sure you do some extra checking to make sure a Site Column doesn't already belong to a Content Type before adding it, etc. in case that change is already in place before the code executes.) This approach means you only have to execute one Feature when creating a new Site Collection, but it also means you're maintaining changes in two places: in your Feature Receiver for making changes to existing sites, and in your CAML for new sites. It's a cleaner approach, but also contains an element of redundancy, which always leaves room for human error.
• The other approach is to simply assume that every time the base CAML feature is activated, you're always going to execute the Feature Receiver. This approach says the only time you'd change the CAML is to add a new Site Column or new Content Type; otherwise, all the changes happen in the Feature Receiver. This approach reduces redundancy, but also means your Feature Receiver code could get quite large with all your changes over time, and it could leave your CAML as very much "legacy" over time.
Src: http://blog.beckybertram.com/Lists/Posts/Post.aspx?List=eb3e1762%2Dbab0%2D4e96%2D8bc5%2Dd67d6e6bfd44&ID=18
Updating Content Types is still one of the underdeveloped portions of Sharepoint which sometimes causes trouble, especially in Content Deployment scenarios.
The best thing in your case would be to always avoid making any changes to content types by hand (using UI)
Whenever you are installing the content type, make sure that you remove the previous one and then install the new one. (Sometimes its not possible due to pages being already created out of it).
My current approach to deploying content types is to do as much as possible using code rather than CAML. That way it is easy to fully control the logic of updates, including ensuring that changes made manually don't cause conflicts. I have the structure defined as attributes on an interface I also use for strongly typed list access, but there are several other ways you could do it.
The only piece that isn't available in the API is setting a specific content type ID, so you need to have a caml file for that, but it's a small/simple file, doesn't try to make updates and is only referenced from a feature that will also run the update code.

SharePoint SPContext.List in a custom application page

I have a custom SharePoint application page deployed to the _layouts folder. It's a custom "new form" for a custom content type. During my interactions with this page, I will need to add an item to my list. When the page first loads, I can use SPContext.Current.List to see the current list I'm working with. But after I fill in my form and the form posts back onto itself and IsPostBack is true, then SPContext.Current.List is null so I can't find the list that I need to add my stuff into.
Is this expected?
How should I retain some info about my context list across the postback? Should I just populate some asp:hidden control with my list's guid and then just pull it back from that on the postback? That seems safe, I guess.
FWIW, this is the MOSS 2007 Standard version.
Generally speaking I try and copy whatever approach the product group has taken when looking to add functionality of my own. In this case they add their own edit/view/add pages via the list definition itself.
I built a solution that also needed its own custom "New" form, not open source unfortunately, though if you are interested you can download it, its called "Tagged Links" (Social Bookmarking for SharePoint) and you can find some links on my blog.
To give you a few hints and tips, the following should set you off in the right direction:
Created a new list definition.
Created a new Content Type In the content type you can define your own "FormTemplates" that references a Rendering Template which determine what gets displayed in the "Middle" bit of those forms.
Copied the standard Rendering Template, but then made the changes to it that I
needed.
Wrapped it all up in a solution, and deployed.
My Rendering Template actually included an overridden "Save" Button where I did a lot of the extra work I needed to do during the save.
Anyway, it is a little too much work in my opinion but, I think, it most closely matches the standard approach taken by the product developers. Let me know if you need more detail and I will see if I can put together a step-by-step blog post, but hopefully this gets you off on the right direction.
I would be surprised if you could do something in a _Layouts file that you can't do in a forms template. You have pretty much the same technologies at your disposal.
Looking at the way SharePoint works with ListItems and Layouts pages (for example "Manage Permissions" on a list item), I can see that they pass some variables in via querystrings:
?obj={76113B3A-FABA-4389-BC85-4BB2CC5AB423},6,LISTITEM&List={76113B3A-FABA-4389-BC85-4BB2CC5AB423}
Perhaps they grab the context back each time programmatically using these values.
I'm not using a custom "new form", so this might not apply. I added an event receiver to my custom content type and then do my custom code in the ItemAdded or ItemAdding events. This code fires when the event is added to a list. You can use the event receiver properties to get to the parent List, Web, and Site.
I'd like to think my issue is "special" here, since I am using a custom form. I chose to use a custom form rather than a custom FormTemplate simply because I'm doing a lot of stuff that's not very SharePoint list-like (making ajax calls to get info from a third-party app then generating some dynamic form elements based on that ajax result, then subsequent processing of that data on postback). I thought it'd be a nightmare to try this within the usual custom rendering template mechanism.
I also don't think I can supply the custom form declarations in the list definition itself, because I have multiple content types associated with this list, and each content type has its own custom form (the other type is thankfully much simpler).
Actually, my simple way of keeping the list guid in my hidden field was a very low impact way to address this specific problem. My main concern is that I'm not sure why the SPContext just loses all its usefulness when I postback here, which makes me think I'm doing something wrong.

Resources