Posts

Showing posts from October, 2011

Auto-Generating SharePoint Filenames for InfoPath 2010 on Submit

Image
SharePoint 2010 InfoPath - Auto Generating Filename on Submit Button 1. Create a filename field Create a strFilename field (Text).  Do not set any conditional formatting, rules, or data validation on this.  Add it to the canvas for now and make it read-only (Fig 1).  This will be visible for testing purposes only. You can hide this if you need to But I left it on my form as I thought it was useful.  (fig1) 2. Create Submit Data Connection Create a SUBMIT data connection in your form template that connects to the Form Library where the form resides.  Put in the URL of your Form Library for the “Document Library” field, and choose the strFilename  data element for “File name” field by using the fx button.  Check the box for “Allow overwrite if file exists” In Infopath 2010 this is done by navigating to the "Data" tab, Clicking on "Data Connections", and clicking "Add" as in (Fig 2).  (fig 2) then click next and select to submit your data "

Copy a SharePoint List Programmatically

I've been working with the SharePoint API lately. One of my tasks is to copy SharePoint lists from one site to another site. This can be done in code as long as the two sites are on the same machine. It's OK if they are in different web applications, but it can't be from one server to another. If you need to copy from one server to another, you either need to do an export/import, or find a way to save the settings and import them on the new machine. I believe you can use the SharePoint Web Services to accomplish this, though. I haven't worked with that yet. Anyway, it took a lot of digging around to figure out all the things I needed to copy lists, so I thought I'd post the code that is working for me. This post is only going to cover copying a basic list. I am planning on several more posts to handle document libraries, wikis, and other special cases. Each has their own challenges. The requirements for me are to copy the bulk of the lists of a large SharePoint

Adding, Deleting, copying and downloading attachments in SPList using C#

using (SPSite oSPsite = new SPSite(" http://website/ url/")) { using (SPWeb oSPWeb = oSPsite.OpenWeb())       {             oSPWeb.AllowUnsafeUpdates = true;             // Fetch the List             SPList list = oSPWeb.Lists["MyList"];                                 //Add a new item in the List             SPListItem itemToAdd = list.Items.Add();             itemToAdd["Title"] = "Test Title";             itemToAdd["Description"] = "Test Description";             itemToAdd.Update();             // Get the Item ID             listItemId = itemToAdd.ID;             // Update the List item by ID             SPListItem itemToUpdate = list.GetItemById(listItemId);             itemToUpdate["Description"] = "Changed Description";             itemToUpdate.Update();             // Delete List item                         // Delete List item           for (int i = list.Items.Count - 1; i

SharePoint - two different views (InfoPath User Roles)

InfoPath User Roles in Browser-Based Forms- Another Way (Part 1 of 2)  : How to Emulate User Roles in InfoPath Forms Services to Automatically Switch Views: http://sharepointsolutions.blogspot.com/2009/04/how-to-emulate-user-roles-in-infopath.html