Skip to main content

Posts

Showing posts with the label custom applications

Issue with ItemDeleting event receivers

When working with event receivers you can use custom error pages. For example and implementation tips you can look here:  http://www.zimmergren.net/technical/sp-2010-how-to-event-receivers-and-custom-error-pages This doesn't work for ItemDeleting event receivers. Illustration The following piece of code:   will produce the following result: We don't see the custom error page as we should as per the article above. Semi-solution We can use just custom message, not the custom page in case of ItemDeleting. Code: Result: Enjoy.

Import Excel files to SharePoint 2010

Sometimes we have a need to transfer Excel spreadsheet to the SharePoint 2010 environment. Because Excel is very popular business application, I see quite a few spreadsheets out there that are used for managing complex business operations. At some stage the decision comes up to move Excel-based system to SharePoint for certain good reasons and business users try to upload their spreadsheets to SharePoint lists and libraries. It might seem obvious that we could use out-of-the-box functionality provided by Microsoft in SharePoint 2010 which is "Import Spreadsheet" which "creates a list which duplicates the columns and data of an existing spreadsheet". What it does in reality is: allowing you to select a range of cells, creating a list with all columns as single or multiple lines text. That's it. So for real life scenarios we need a different approach to import Excel data to SharePoint appropriately. In the scenario here we have got a simplified application manage...

VG Content Display Web Part for SharePoint 2007 Released

Wylde Solutions released a SharePoint 2007 (MOSS 2007 and WSS 3.0) version of VG Content Display Web Part . VG Content Display Web Part is an alternative to Content Query Web Part (CQWP). It is easy to set up, uses custom XSLT file and it works with SharePoint 2010 Foundation. It allows displaying context-related content using current page metadata as filter values.

Google Maps in SharePoint

I have found some resources recently about the subject: 1. It's All About Location - Embedding Google Maps in SharePoint This example uses Content Query Web Part and is static which is normally not the real-life scenario. 2. Google Map SharePoint Web Part This is a product that looks nice and delivers what is normally wanted. 3. SharePoint Google Map This is a custom field that can display Google Maps for user. It looks like there are some limitations when you use that control. 4. Using Google Maps to Display Geographical Information in SharePoint This is a nice technical article which exlpains how you can make it. 5. Add a Google Map to SharePoint Video article. Stay tuned and mapped. :)

How to add custom property/properties to SharePoint features

Here's the article about how to add custom property/properties to SharePoint features: Adding Custom Properties to Sharepoint Features Though this is pretty useful in order to provide different values to the feature's property you have to deactivate and activate the feature again so be aware that if your feature does some clean-up on deactivation it can be gone with feature property change.

Key Performance Indicators - Create KPI List and indicator programmatically

Scenario We need to create KPI List and an Excel Workbook indicator programmatically. Solution 1. Create an Excel Workbook: 2. Upload that workbook to the document library on our Web site: 3. Add trusted location to Excel Services settings: 4. Create a project in Visual Studio which will do the following: SPListTemplate template = null; foreach (SPListTemplate t in sweb.ListTemplates) // sweb - SPWeb object that we initialized before { if (t.Type.ToString() == "432") // this way we can pickup the KPI List list template { template = t; break; } } Guid gG = Guid.Empty; SPList list = null; string sListTitle = "Mighty KPI List"; try { gG = sweb.Lists.Add(sListTitle, sListTitle, template); list = sweb.Lists[gG]; } catch { // exists list = sweb.Lists[sListTitle]; } // in our case we need Indicator using data in Excel workbook content type SPContentType ct = list.ContentTypes["Indicator using data in Excel workbook"]...

Mighty SharePoint Workflows - part 4 - Start/restart SharePoint workflow programmatically

Scenario We want to start or restart SharePoint workflow programmatically for the list item. Solution SPList list = ...; // initialise your list SPWorkflowAssociation workflowAssociation = null; workflowAssociation = list.WorkflowAssociations.GetAssociationByName("Mighty Workflow", System.Globalization.CultureInfo.CurrentCulture); if (workflowAssociation != null) { foreach (SPListItem item in list.Items) { foreach (SPWorkflow wf in item.Workflows) { if (wf.AssociationId == workflowAssociation.Id) { // if we want to restart - cancel the running one first if (!wf.IsCompleted) { try { SPWorkflowManager.CancelWorkflow(wf); } catch { } } // ...

Maintaining Control Focus on Postback in ASP .NET

I have recently got an issue with massive ASP .NET Web Form which is needed for a lot of details to be entered and takes several screens to display. When you edited something in the middle of the form and initiate a postback - the form was displayed from the top. In my case Web Form was a part of custom Web Control which is rendered within the SmartPart for SharePoint . I found the following article which helped me - How to implement the smart navigation features in ASP.NET 2.0 . I put the following instruction in the OnInit event handler for my Web Control: this.Page.MaintainScrollPositionOnPostBack = true; It helped! Now when I do something on postback my Web Control scrolls back to the place I edited last. Simple but powerful.

SharePoint 2007 Integration With Dynamics CRM - Solution - Part 1

The Scenario An organization has relationships with third-parties. Accounts, customers, members, suppliers etc. The organization has a SharePoint Web site and Dynamics CRM where the information about third-parties is processed. As the current business process dictates, large number of external clients - agents in this sample - needs to contact organization via email, fax, regular mail or in person in order to submit important business information - applications in this scenario. We will create a public SharePoint Web site where agents can submit applications and then those applications will be copied automatically to Dynamics CRM and when their processing in CRM is finished some feedback will be published back to the SharePoint Web site and agents will be able to see the status of the application in CRM online on the SharePoint Web site. We defined the solution design as below: In order to get the solution we defined the following tasks: 1. Develop a custom SharePoint Workflow which w...

Mighty SharePoint Workflows - part 3 - workflow history and audit solutions

I came across the limitation of the workflow history in SharePoint the other day. After 60 days the history is cleaned up. Technically it's the right way of doing things in SharePoint, because workflow history is a list and if we have more than 2000 records in the list we have performance issues. There are some blog posts about that issue. The main one: Huge MOSS Workflow Issue... What is Microsoft Thinking!!!! The other linked to the issue: SPWorkflowAssociation.AutoCleanupDays I worked with several clients on custom workflows for SharePoint and we created the separate audit database where all the SharePoint workflow activity information and list/library item information is stored. For guys who have already created workflows in SharePoint or use standard SharePoint workflows - like Approval etc. - and they are not sure what to do the solution is to develop or purchase a tool to migrate their workflow history to separate database on a regular basis. I can help with that...

Connect SharePoint Web Parts Programmatically

The task Send data from one Web part to another. Scenario could be like one Web part contain the list of items - say video, images or clothes catalog - and the other Web part displays detailed view of the catalog item. Solution 1. Create Web part which will send data - data producer. 1.1. When the Web part class is created we need to inherit that class from ICellProvider. The class definition will look like the following: public class DataProviderWebPart : Microsoft.SharePoint.WebPartPages.WebPart, ICellProvider { ... } 1.2. Define the following properties: public event CellProviderInitEventHandler CellProviderInit; public event CellReadyEventHandler CellReady; private int _nCellConnectedCount = 0; private string _sCellInput; private string _sCellName; private string _sCellDisplayName; 1.3. Override the following methods: EnsureInterfaces, CanRunAt, PartCommunicationConnect, PartCommunicationInit, PartCommunicationMain, CreateChildControls. public override void EnsureInterfaces() ...

Mighty SharePoint Workflows - part 2 - workflow statistics, workflow tasks, workflow history

The task 1. Get links to workflow statistics. 2. Get workflow tasks programmatically. 3. Get workflow history programmatically Solution 1. Links to workflow statistics: foreach (SPWorkflow wf in list_item.Workflows) { string sLink = string.Format("{0}/_layouts/WrkStat.aspx?List={1}&WorkflowInstanceID={2}", web.Url, wf.ListId, wf.InstanceId) } web.Url above is the Url property of SPWeb instance. 2. Workflow tasks: foreach (SPWorkflowTask wt in wf.Tasks) { // get any information you like about the wt object, i.e. in this scenario we will output link to the task string sLink = string.Format("{0}/Lists/{1}/DispForm.aspx?ID={2}", web.Url, SPEncode.UrlEncode(wt.ParentList.Title), wt["ID"]) ... } 3. Workflow history: Class SPWorkflow has a member HistoryList which represents history list for the workflow. Let's assume that we are using the SPWorkflow object - wf - from above. 3.1. First we have to make a query to extract history list item ...

Comprehensive BDC Overview

Recently I have come across a set of article about BDC. I haven't seen anything more informative yet. Here it is: Part 1, BDC Purpose and technical architecture Part 2, Application Definition File (ADF) and its Development Part 3, Developing an ADF to Connect to Web Services Part 4, Consuming Business Data through Web Parts and SharePoint Lists Part 5, Implementing Enterprise Search with Business Data Part 6, Integrating User Profiles with Business Data Part 7, BDC Object Model

Mighty SharePoint Workflows - part 1 - workflow association, workflow instance

The task Display SharePoint lists or libraries with active workflow associations. Display item that have running or completed workflow instances and workflow status for this item. In our scenario we have a document library with associated Disposition Approval workflow started on the document: Solution 1. Get Workflow Association data for the certain list or library. SPList list = ...; // Initialize your list instance here if (list.WorkflowAssociations.Count != 0) { foreach (SPWorkflowAssociation workflowAssociation in list.WorkflowAssociations) { Guid gId = workflowAssociation.Id; string sName = workflowAssociation.Name; ... // output the values you have got // in our scenario we add them to Hashtable object hashtable.Add(gId, sName); } } 2. Get workflow instance data for the certain list item or document. We can access workflow instance data from the Workflows property of SPListItem object: foreach (SPListItem item in list.Items) {...

Working with SharePoint Workflows

SharePoint 2007 out-of-the-box provides ability to associate workflows - simple pre-installed like Approval, Disposition Approval, Three-state etc. and custom workflows - with SharePoint lists or libraries. What is missing - at least in this version of SharePoint - is the ability to monitor running and/or completed workflows across the whole SharePoint Web site. As a step forward I have developed a Web part which allows people to monitor workflows across the Web site and sub-sites. I have also developed numerous custom workflows for SharePoint using Visual Studio. This post is the first in series of articles about working with SharePoint workflows programmatically. In the coming posts I will show you how to manage workflows programmatically in SharePoint. Stay tuned. :) Update: Below are the links to articles. Mighty SharePoint Workflows - part 1 - workflow association, workflow instance Mighty SharePoint Workflows - part 2 - workflow statistics, workflow tasks, workflow history Mighty...

Uploading file to SharePoint with metadata update

The task Programmatically upload file to SharePoint document library and update document metadata. In our scenario we will have an XML document to upload. Solution 1. Get the file contents as byte array 2. Add file to the SharePoint SPFolder object 3. Update corresponding item metadata XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(" "); using (MemoryStream ms = new MemoryStream()) { try { xDoc.Save(ms); SPFolder folder = null; SPWeb web = ... // Initialize your SPWeb object here folder = web.Folders["your_document_library_site_relative_URL"]; string sFileName = "my_new_file_name.xml"; SPFile file = folder.Files.Add(sFileName, ms.ToArray(), true); // true in Add method above is to say that we overwrite the file if it exists SPListItem item = file.Item; item[item.Fields["my_metadata_column_display_name"].InternalName] = "some_value"; ... // provid...

Coding Practice for SharePoint 2007

I have started creating a Coding Practice for SharePoint. Some sort of documentation to help me and my friends developing custom applications for SharePoint. I did a quick search about that theme and have got the following links to start drilling down into the subject: Best Practices: Common Coding Issues When Using the SharePoint Object Model Best Practices: Using Disposable Windows SharePoint Services Objects Checklist for Creating SharePoint Web Parts Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 1 of 2) Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 2 of 2) Design Guidelines for Class Library Developers C# Coding Standards SharePoint Development Best Practices – Checklist