Thursday, August 28, 2008

steps for deploying infopath forms in sharepoint workflow

You can find a step by step process on this site:

http://weblog.vb-tech.com/nick/archive/2007/02/25/2207.aspx

its written in a very simple way with no chance of being distract.

Check it out, and can contact me incase of any query.

Wednesday, August 13, 2008

Adding a Custom Content-Type Specific Item on a SharePoint List

I have a custom content type called “CustomItems” on my SharePoint list. I want to add an item to that list which will use the “CustomItems” content type. And i want to do it programmatically.

I don't know how to do it and I am finding the solution (yes still finding it). I have searched on google and find this site helpful

http://asadewa.wordpress.com/2007/11/19/adding-a-custom-content-type-specific-item-on-a-sharepoint-list/

but after performing all the mentioned steps, i am getting this error:

"To Add an Item to a document Library, use SPFileCollection.Add()"

I have spent a whole week to find the solution and now i m posting it to help you all.

My requirement was to add a custom content type item in a document library, the above link is to add the item in a task list not in a document library that is why i was getting the error.

I had a custom content type Called "BIR-Form".

Following are the simple steps to do it:

  1. Upload this content type template anywhere in your site or place it on the file system at: "c:\windows\system32\inetsrv\ContentTypeTemplateFormName.xsn", i have used the second method.
  2. Write this code in your ItemAdded Event:


SPSite mySiteCollection = new SPSite("http://demo/");
SPWeb myWeb = mySiteCollection.RootWeb;

SPFolder folder = myWeb.GetFolder("CustomContentType");

FileStream fs = new FileStream("ContentTypeTemplateFormName.xsn.xsn", FileMode.Open);
byte[] fileContents = new byte[(int)fs.Length];
fs.Read(fileContents, 0, (int)fs.Length);
fs.Close();

SPFile file = folder.Files.Add("BIR.xsn", fileContents);
SPDocumentLibrary docs = (SPDocumentLibrary)myWeb.Lists[folder.ContainingDocumentLibrary];

SPContentType itemtype = myList.ContentTypes["BIR"];
SPListItem item = docs.Items[file.UniqueId];
item["ContentTypeId"] = itemtype.Id;
item.Update();

Change the value of fields and don't forget to call the update method.

Monday, August 11, 2008

using the master page from your site in custom _layouts pages

To use the master page on your site in custom _layouts i followed http://www.sheltonblog.com/archive/2007/10/05/free-sharepoint-document-workflow-workshop---part-2-asp.net-workflow.aspx article but after executing this application i get the error:

The virtual path '/_catalogs/masterpage/default.master' maps to another application, which is not allowed

I cheked the above link and found in comments that, if you are trying to deploy your workflow to the root-site, make your files project a "file-system Website" not an HTTP Website.

I did this but still i was getting this error and was really in trouble.

After searching a lot on google and trying different things i found the solution.

Simply go to your project web.config and comment this line
'authentication mode="Windows" '

Hope this will help you. waiting for your comments.

Friday, August 1, 2008

How to Deploy an InfoPath 2007 Form Containing Managed Code to a Browser-Enabled WSS v3 Library

InfoPath Forms Services is NOT part of WSS v3. It is a separate install, or you can install it as part of the MOSS 2007 Beta 2 install. The RTM version, last I heard, will be available as a separate SKU or as part of MOSS 2007 Enterprise Edition.

Assuming you have already created an InfoPath form containing managed code, this document will explain the steps necessary to deploy it to a WSS form library that is “web-enabled” by InfoPath Forms Services.

Publish the Template to the File System (or file share)

Note: In Office 2007 you can’t publish an InfoPath form containing managed code directly to a WSS form library because it has to be first approved by a WSS Administrator.

1. Open the Design Tasks task pane and choose Publish Form Template.

2. Choose the first option, to publish to SharePoint, and click Next.

3. Enter the location of the SharePoint site you want to publish to.

4. You will be presented with the screen below. Make sure the checkbox is checked to enable the form to be filled out in a browser and click Next.

5. You must choose a location to save the template file, which will be uploaded to the SharePoint site by the site administrator.

6. Specify any columns you want to be made available as WSS columns in the form library.

7. Verify that the information is correct and click Publish. The form will be published to the specified file share location.


Upload the Template to the Central Administration Form Templates Library

1. Go to the Central Administration site for your farm (or web server if there's only one)

2. Click on the Application Management tab, go down to the InfoPath Forms Services section, and choose Manage Form Templates.

3. The Form Template library is opened, which is where admin-approved form templates for the farm are stored.

4. Click Upload Form Template. Choose your saved template file and click the Verify button. You will be shown any errors or warnings related to your template file. Read any warnings (hopefully there are no errors) and click OK.

5. Choose your template file again (Why is it not persisted in the text box between postbacks??). In the Upgrade section, you can choose to upgrade the form template if it already exists. You can also choose how to handle current sessions that are using the form template.

6. Click the Upload button to upload the form template. It is now available as a Feature to be activated on any site collections in the farm.

Activate the Form Template on a Site Collection

1. You can activate a form template feature from the Manage Form Templates page of Central Administration (the same page where you uploaded the template). On the context menu of the newly uploaded form template, choose Activate to a Site Collection.

2. In the Activation Location section of the page, choose the appropriate Site Collection and click the OK button.

Note: You may actually have to change Web Applications to find the site collection you are looking for. A Web Application maps to an IIS virtual server.

Associate the Form Template with a Form Library

1. Create a new form library (or use an existing one, it really doesn't matter),go to the settings page. and choose Advanced Settings.

2. Choose Yes for Allow management of content types. For Opening browser-enabled documents, choose Display as a web page.

3. Click the OK button to go back to the Form Library Settings page.

4. There should now be a Content Types section which displays the Content Types enabled for the form library. The form template feature that you activated added a new content type to the Site Content Type Gallery.

5. Choose Add from existing site content types and find your form template. Click on it and click Add, then click OK.

6. Go back to your form library, click the New dropdown, and choose your form template. It will be opened in the browser window where it can be filled out and saved or submitted.