Code Snippet to remove duplicate workflow associations from a content type

1: using (SPSite site = new SPSite("http://ms9:105")) 2: { 3: using (SPWeb web = site.OpenWeb()) 4: { 5: SPList list = web.Lists["Shared Documents"]; 6: 7: foreach(SPContentType con in list.ContentTypes) 8: { 9: if (con.Name == "Document") 10: { 11: SPWorkflowAssociationCollection assocCol = con.WorkflowAssociations; 12: bool App = false; 13: bool Feed = false; 14: bool…

0

Code snippet to download the files along with versions from SPS 2003 document library.

1: private void Download() 2: { 3: string siteUrl = txtSite.Text.ToString(); 4: string source = txtDocLib.Text.ToString(); 5: string downloadPath= txtDownload.Text.ToString(); 6: byte[] vContent = null; 7: int count = 1; 8:   9: using (SPSite site = new SPSite(siteUrl)) 10: { 11: using (SPWeb web = site.OpenWeb()) 12: { 13: SPFolder sourceFolder = web.GetFolder(source); 14:…

0

Code snippet to add / modify columns in a list

It iterates through a whole site collection and wherever the list with name “test” it finds, It will do the changes. 1: using System; 2: using System.Collections.Generic; 3: using System.Text; 4: using Microsoft.SharePoint; 5:   6: namespace ConsoleApplication1 7: { 8: class Program 9: { 10: static void Main(string[] args) 11: { 12: using (SPSite…

0

Code sample to aggregate the text from "append changes" column to Multiline text field.

This is a code sample to copy all of the text from the “col1” column to “col2” column. To note again, “col1” is an "append changes" column so the previous edits of the comments field are stored in previous versions of the list item. 1: using System; 2: using System.Collections.Generic; 3: using System.Text; 4: using…

0

Ways to pass security credentials to web service call

[1] 1: WS.Credentials = new System.Net.NetworkCredential(userName, password, domain); If you want to pass explicit credentials and filter the record after that.   [2] http://support.microsoft.com/kb/813834 1: myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials It will pick up the current logged in users’ credentials and return the data for him/her.   [3] Using SharePoint object model, setting up our custom web…

0

Code to subscribe the User for alert notifications from a list

1: SPWeb web = SPContext.Current.Web; 2:   3: SPList list = web.Lists["Pages"]; 4:   5: SPUser user = web.CurrentUser; 6:   7: SPAlert alert = user.Alerts.Add(); 8:   9: alert.Title = "My Alert"; 10:   11: alert.AlertType = SPAlertType.List; 12:   13: alert.EventType = SPEventType.All; 14:   15: alert.List = list; 16:   17: alert.AlertFrequency…

0

How To: Access item metadata from workflow when associated in document library

Problem There is a workflow which accesses the item metadata on workflow activated. In case of document library, when you upload a document, if the workflow is set to start on ItemAdded, it will start just after upload is done and before you completely fill up the metadata information of the item. Since it is…

0

In SPS 2003, Use custom template to create the document workspace through ECB menu link.

In SPS 2003, In the ECB menu of the documents we get an option “Create Document Workspace”. This link uses the OOB document workspace STS#2 to create the document workspace. There was a requirement to use our own custom template to create the document workspace through this ECB menu link. Resolution We started troubleshooting the…

0

How to: Enable Edit option for non anonymous comments in blogs

We have implemented an internal blog site using the MOSS 2007 blog template. One of the requirements was to support anonymous comments. Since this is not an out-of-the-box feature, we searched and found a solution on the Microsoft SharePoint Team Blog site, http://blogs.msdn.com/sharepoint/archive/2007/08/06/anonymous-comment-feature-for-sharepoint-blog-now-available-on-codeplex.aspx We implemented the custom web part, which is working out great. Unfortunately,…

0

Resolution: Problems with Ajax development/ Page does post back

If the you have applied bluband.master then we need to do changes in bluband.master per the solution step [2] [1] Webpart change Add following code in your webpart and call it in CreateChildControls //in CreateChildControls method //Fix for the UpdatePanel postback behaviour.             EnsurePanelFix(); private void EnsurePanelFix()         {             if (this.Page.Form != null)            …

0