Skip to content

WebCast Live from TechEd – Workflows

For those of you who didn’t get to see this. I did the workflows web cast on MSDN from the floor of TechEd North America. Here’s a picture that Paul Andrew took to prove it.

Web 2.0 Heroes

Book Review-Web 2.0 Heroes

If you’ve read this blog for a while you know I’ve been on a journey to try to figure out social networking and through extension Web 2.0. I’ve read Wikinomics, Blink, The Wisdom of Crowds, Linked, and The Long Tail. It would be pretty easy to see how I might get exhausted by the topic of social networking. However, my buddy Brad Jones started talking about the project, I was intrigued. We have regularly scheduled lunches and we were talking about how some terms in the computer industry don’t really have a firm definition. One of those was Web 2.0. He decided to embark on a project to interview 20 of the leaders of the Internet and ask them what they thought Web 2.0 meant.

Before I started reading his book, Web 2.0 Heroes: Interviews with 20 Web 2.0 Influencers I had about as much chance of defining Web 2.0 as launching myself to the moon with Mentos and Diet Coke. At the end, I don’t know that I can truly crystallize it into one answer – however, I can share common themes:

  • Enabling People to do things easily.
  • Interactive two-way and multi-way conversations
  • The intersection of people, process, and technology

I know as formal definitions go it’s not the best, but I can say that I feel like I can defensibly talk about Web 2.0 and have some valid opinions to back mine up. (It’s been said that best practices in the computer industry are just having someone that you trust saying that’s the way they do it too – so why can’t I use a similar definition for terms?)

The book isn’t going to make the New York Times Best Seller list – but it may help you build – and defend – your own definition of what Web 2.0 is.

Now if we can just get a similar thing on SOA, RIA, etc. we might be able to understand each other. In the mean time get started with Web 2.0 Heroes.

Article: Managing the Code when Customizing SharePoint

One of the most common problems that organizations that are customizing SharePoint have is how do they manage the code deployment process. Organizations typically have configuration management guidelines that help them regulate how code makes it into production whether that’s internally developed code or are patches that are applied to the operating system and products being leveraged.

The problem is that SharePoint doesn’t fit a nice clean model. Because so much of SharePoint is configuration and data driven, code that works in development or a test environment may not work in Prod because things are configured differently or there’s different data to operate on.

So how do you manage a situation where you’ve got configuration information that needs to meet up with code to create a complete solution? In this article I’ll tackle this problem, a generic approach, and talk about a few of the sharp edges on the strategy that you’ll have to educate everyone on.

More?

http://www.intranetjournal.com/articles/200806/ij_06_09_08a.html

You’ve got Questions (About Workflow), here are the Answers

Thank you to everyone who joined the Workflow web cast on Wednesday. My apologies for the somewhat abrupt ending to the call as the telephone I was speaking on dropped. However, as promised, please find my responses to the questions that were asked.

Q: If the WSS Workflow is 3 steps, is that the same for MOSS?
A: No, The OOB MOSS templates for approval isn’t constructed the same.

Q: What are the maximum number of steps that you can have in a workflow?
A: I don’t know what the specific number is but it’s more than would be practical to have in a workflow.

Q:What is the best practice for generating workflows that can be upgraded?
A: If it’s a bug fix, you can recompile the DLL and redeploy. You’ll need to temporarily stop the web site, the timer service, and the administration service to redeploy the file into the GAC. If you’re deploying an updated workflow with new steps, it’s best to deliver a new workflow – and let the current instances of the old workflow die off.

Q:Is there a way to edit and modify the out-of-the-box templates with Visual Studio?
A: Unfortunately, No. You can only create new workflow templates not modify the out of the box templates.

Q:SharePoint is the host for my workflows, how can I get a direct handle to the WorkflowRuntime to get notified on WorkflowStarted, etc.?
A: No, SharePoint has to manage the runtime. There’s no facility to get access to the runtime.

Q: When will the Visual Studio Extensions for Windows SharePoint Services be available for Visual Studio 2008?
A: It was announced at TechEd 2008 | North America this week, that the VSeWSS Version 1.2 (which supports VS2008) will be available by next Monday.

Q: What’s the difference between a pure WF workflow and a SharePoint WF?
A: The biggest difference is a SharePoint WF begins with a specific OnWorkflowActivated activity that wires things up. You also get access to a larger set of out of the box activities, and the details around hosting the WF runtime are handled for you.

Q: Why do workflows have to go in the GAC?
A: It’s complicated but essentially it has to do with being able to find and load the DLL running from different contexts.

Q:How do you activate/deactivate a workflow that is deployed to all of the site collections in a web application?
A: There’s no out of the box way to do this. However, the code is relatively trivial. See the below…

public static Sample(Guid featureDefId, string Url)
{
using (SPSite site = new SPSite(Url))
{
SPWebApplication webApp = site.WebApplication;
foreach (SPSite webAppSite in webApp.Sites)
{
webAppSite.Features.Add(featureDefId, true);
}
}
}

Q: How would you migrate custom workflows across SharePoint Farms?
A: Packaging the workflow template in a SharePoint Solution (WSP) file would allow you to deploy the template across farms. Workflows created in SharePoint Designer cannot be migrated.

Q: Can you hide fields that you’re using to manage approvals?
A: Yes, absolutely. When you define the field you set HIDDEN = True as an attribute of the <Field> tag.

Q: Can you allow something to be approved by three people?
A: Yes, either by specifying a group or by using the Repeater and creating one task for each of the three people. The out of the box MOSS Approval workflow is a good way to see some of the options.

Q: I want to bulk upload documents and parse out some metadata. Should I use a Event Receiver or a Workflow?
A: Event Receiver. Event Receivers are quicker and lighter weight. IF you don’t need human interaction or a long running scenario, event handlers are a better choice?

Q: What type of list is being used for the workflow tasks?
A: It’s a standard tasks list. The workflow runtime automatically associates your content type with it.

Q: Where will the source code from this presentation be available?
A: At http://www.microsoft.com/downloads/details.aspx?FamilyID=25f9cc59-4ea3-4381-8b37-9430f664eac6&displaylang=en

Q: Is it possible to have a global view of all instances of running workflows in SharePoint?
A: Not easily and certainly not out of the box. You would have to build this yourself.

Q: Where do you do the strong naming of an assembly in Visual Studio 2008?
A: Project properties, just like in VS 2005.

Q: What security credentials is the workflow processing under?
A: It’s actually running under the application pool account for the web application that hosts the workflow, however, it’s made to look like the current user as much as possible. From a security management perspective you must be careful about what code is allowed to run as a workflow because it’s a highly privileged token that it can get to.

Q: What do you think about third party workflow offerings?
A: They have their place. Building Visual Studio workflows can be difficult. Third party tools make that process easier.

Q: Does the type for a workflow task need to be assigned to the task list the user chooses?
A: No, SharePoint will add the content type to the workflow tasks list.

Q: How do you find the ID of the new custom task content type?
A: You don’t, you define the content type via a feature so that it doesn’t change.

Q: Are you using a workflow task list?
A: It’s a regular task list. SharePoint added the content type for me.

Q: Can I use workflows with Outlook Tasks?
A: No, they have to be SharePoint tasks, however, the normal SharePoint to Outlook integration rules appy.

Q: Is InfoPath required to create the workflow forms?
A: No, you can also code them in ASPX (Visual Studio) if you would like.

Q: Can an Activity’s properties can be shared between different workflows?
A: No, however, with activity binding they can be shared between two different activities in the same workflow instance.

Q: Is there an online community site with prepackaged workflows for common scenarios?
A: I’m not aware of any.

Q: Can you develop a custom activity in Visual Studio and then use it within SharePoint Designer?
A: Yes, that’s my final example in my talk this morning on developing Custom Workflow Activities at TechEd 2008 North America. Basically you have to add an authorizedType entry into the web.config and create a .ACTIONS file and add that to the server.

Q: Can you debug a workflow?
A: Yes, you can attach to the IIS worker process with Visual Studio. Just make sure that you only attach the workflow debugger. It has the CLR debugger pieces in it. The SQL debugger conflicts so it should definitely be removed.

Q: Can you debug a SharePoint Designer workflow?
A: Not to my knowledge.

Q: Can a workflow access an external database?
A: Sure. It’s standard .NET code that’s running inside the activities.

Q: How can I handle the cancel event if the user is clicking the “Terminate Workflow Now” link on the status page?
A: If you right click on the white area in the workflow designer you’ll see options for fault handlers and cancel handlers (or whatever the specific text is.) They can be used to handle “extordinary” flow events like the workflow being cancelled.

Q:What’s the best practice for starting workflows on SharePoint Surveys?
A: I’ve never tried it. I’d suspect the standard rules apply. I don’t recommend having both Automatically start on Creation and Automatically start on Change… but other than that I don’t think that there are many “best practices”

Q: Can you break down the content type for a workflow task again?
A: Sure. The ID is 0x010801. The first 01 is Item, the 08 is Task, the final 01 is Workflow Task.

Again, I want to apologize for the call dropping during the question and answer portion of the talk.

Full Speed Ahead for SharePoint Development – All You Need has Been Released

If you’ve listened to the web casts that Andrew Connell and I’ve been doing for Paul Andrew, you may have noticed something strange. We’ve been talking about the source code for the demos being available at http://mssharepointdeveloper.com – and some folks have been commenting that the site doesn’t go anywhere. However, that is no longer the case. The site went live today. Great – but why should you care?

Well, the web casts are just the tip of the iceberg. In addition to the web cast materials you’ll also find a complete set of hands on labs for the same 10 topics. Just in case you’re wondering, it’s not the same demos that you see in the web casts. Instead they’re complete projects that you can build yourself that cover the same general concepts.

But wait there’s more… (Trying my best late night TV product sales guy voice) You can also see a video that Andrew, Paul and I recorded talking about how Andrew and I got started in SharePoint – and why the landscape is different. (You can find it on the home page of http://mssharepointdeveloper.com)

Finally, there’s also a whitepaper that’s available which talks about what a developer should know about SharePoint in more of a narrative form.

In short, no matter what you’re learning style you should be able to get up and running with SharePoint development in less than 10 hours.

On a more personal note, I’m very happy with the quality of these materials. Sure there are things that I’d like to change, but they’re more complete and more real world than any other set of materials that are available publically. We’ve all tried to make sure that you could start getting stuff done with SharePoint at the end – and to make sure that you can get out the other end with a broad understanding of some of the cool stuff you can do with SharePoint. I’m glad we can finally talk about the full breadth of the campaign!

Web Cast Q&A Follow up: Web Parts and Data Lists

I got a lot of great questions during the web casts for the Introduction to SharePoint for Developers series that Andrew Connell and I are doing for Paul Andrew. Specifically, the Web Parts and the Data Lists web casts. I wanted to share the Q&A here since there’s no good place for the Q&A to appear on the MSDN web cast site. So here’s the Q&A from the Web Casts event (slightly edited):

Web Parts

Q: Would it be possible to have a web part in another web part?
A: Yes, Web parts are fundamentally just server controls. Controls in the ASP.NET control tree can nest other controls.

Q: Do the Visual Studio Extensions for Windows SharePoint Services (VSeWSS) require that you develop on Windows Server?
Q: Is it better to do my development on the WSS Server or can I just as easily develop on a client machine and deploy to a development WSS Server?
A: Anything that you do with the SharePoint API requires that you be developing on the same server as SharePoint. Since SharePoint only runs on a server OS – you have to develop on a server OS. Typically you do this in a virtual machine.

Q: Have the Visual Studio Extensions for Windows SharePoint Services with support for VS 2008 been released yet, or is there an announced ETA on them?
Q: When will the SharePoint Extensions be available for VS 2008
A: Paul Andrew says “June 2008”

Q: Isn’t the “Full” trust level an ASP.NET framework Code Access file which can be used in WSS? I thought WSS had only 2 built in CAS files defined.
A: Full isn’t actually a file, it’s a hardcoded setting that turns off Code Access Security. However, you are correct in that this is a part of the ASP.NET core and not something that SharePoint added.

Q: What version of Visual Studio supports the SharePoint Solution?
A: Visual Studio 2005 with the SDK and with the Visual Studio Extensions for Windows SharePoint Services is what I showed. Visual Studio 2008 has support for Workflows but doesn’t have support for web part development.

Q: Why are your local property backing fields declared protected and not private?
A: It’s an OO design thing. I only make my backing fields private if there’s a specific reason why they shouldn’t be touched by subclasses. If there’s no code reason to protect them from subclasses I don’t. One could argue best practice with me about this but I feel strongly that classes should make variables protected rather than private where possible.

Q: We use a lot of user controls in our MOSS publishing sites which are public facing. Should we be using web parts or does that not make sense for a publicly accessible web site?
A: I don’t think user controls are bad. I show at the end of the presentations how to load them in a web part. There are some situations (like field controls) where user controls make a ton of sense. There’s no right or wrong answer.

Q: What are the drawbacks of implementing our own interface passing element rather than using the IWebPartField interface? Any issue with SharePoint Designer?
A: Implementing your own interface means that you have to write the web parts to both produce and consume the information. The standard interfaces can connect web parts that you don’t write. The generic interfaces require you know a bit more about type descriptors so are more difficult to work with – but more flexible. I haven’t ever tried to connect web parts in SPD that use a custom interface but I assume it works.

Q: I noticed that the full webpart page needs to reload in your connected web part example. Is there a way to pass data without reloading the full web part page? Is it possible to use AJAX?
A: I’m getting a definitive answer here. However, the framework expects full page refreshes, it may be possible to work around this. I’ve asked Dan Larson (SharePoint MVP and champion of AJAX) if he knows of a workaround. I’ll post an update with his response.

Q: My deploy of your basic web part to SP yielded the error ‘No SharePoint site exists at the specified URL’ where do I specify the URL?
A: In the project properties, (Right click the project select properties) Click the debug “page” it’s the place where it says start a browser with this URL.

Q:What was the site where the source code is going to be available again?
Q: Where can we get demo code from and download it?
Q: Where can I download the sample code and slides?
Q: What was the url to download the code?
Q: What was the Url of the site where the source code will be posted
A: mssharepointdeveloper.com It was also posted at http://www.microsoft.com/downloads/details.aspx?FamilyID=25f9cc59-4ea3-4381-8b37-9430f664eac6&displaylang=en if you want to get it before it’s available on mssharepointdeveloper.com

Q:Is there any way to pass the MOSS user information to your web part so it can pull data based on the logged in user?
A: It’s already there. If you do SPContext.Current.Web.CurrentUser you get the SPUser object for the current logged in user. There’s a similar way to get the current user’s MOSS profile – but I don’t remember that off the top of my head.

Q: How do you make custom properties not web browsable?
A: Use the attribute WebBrowsable(false) – or don’t include the WebBroweable attribute at all

Q: When will we get a real designer experience for SharePoint Web Parts in Visual Studio?
A: This isn’t a SharePoint issue. It’s a Visual Studio issue for server controls (from which Web Parts derive.) I don’t have an answer here – however, my thoughts are not soon. Particularly since you can load user controls if you want.

Q: What if I want to reference a javascript or image file in my web part – Where does it go and how do I include it in the package?
A: I’ve got an article “SharePoint Localization Tips and Tricks” which shows you how to deploy resource files with your Web Part. It should have what you need.

Q: Can you recommend a book to get started on how to create SharePoint Web Parts as well as Server Deployment and Management?
A: For development, I’d recommend “Real World SharePoint 2007: Indispensible Experiences from 16 WSS and MOSS MVPs” (Disclosure: I contributed a chapter to this book and tech edited the rest), or “Inside Windows SharePoint Services 3.0“. For Deployment and Management I recommend “Microsoft Office SharePoint Server 2007 Administrator’s Companion

Q:Is Integration between SharePoint and SQL Reporting Services possible?
A: Yes, check out Microsoft SQL Server 2005 Reporting Services Add-in for Microsoft SharePoint Technologies.

Q: Is it possible to connect user control web parts?
A: Yes, you just need to implement the interfaces and have your wrapper web part call the interfaces in the user control web part. However, I would consider writing them as web parts directly if you’re going to use SharePoint specific functionality or interfaces like connections.

Q: Where do I get a copy of the VPC image that you’re using today?
A: It’s available at http://www.microsoft.com/downloads/details.aspx?FamilyID=1beeac6f-2ea1-4769-9948-74a74bd604fa&DisplayLang=en

Q: Do we have to install Visual Studio 2005 on the Server or can we develop web parts in Windows XP or Vista?
A: You can develop ASP.NET 2.0 web parts on XP or Vista. If you need to use any SharePoint specific functionality you’ll need to develop on a SharePoint Server.

Q: Can you install these extensions (VSeWSS) on Windows XP?
A: No, they must be installed on a server with SharePoint installed.

Q: Are there any best practices for caching web parts?
A: There aren’t best practices for caching web parts per se. Caching data is really driven by the data that you’re displaying and caching. This is something that should be evaluated on a case-by-case basis. However, you have a configuration point in terms of the persistable properties. Because of that you can make your caching solution something that the end user can tune.

Q: Are the connection interfaces supported by the out of the box SP web parts documented somewhere? Can a custom part implement more than one type of provider interface?
A: I’ve not seen a comprehensive list of the interfaces exposed by the out of box web parts. However, you can discover what interfaces are supported yourself by using the .NET reflector on the classes of the web parts. You can support more than one kind of interface.

Q: I have VS2005 but I am not able to create webparts, how do I add that capability?
A: Download and install the Visual Studio Extensions for Windows SharePoint Services 1.1

Q:Any special considerations for AJAX?
A: Yes, look at www.codeplex.com/Features there’s a AJAX configuration feature that helps. Dan Larson is the guy that knows SharePoint and AJAX best.

Q: I’m having problems where the custom properties don’t display when I inherit from System.Web.UI.WebControls.WebParts.WebPart but they do when I use Microsoft.SharePoint.WebControls.WebPart. What can be wrong?
A: Make sure you include the following three attributes when deriving from the ASP.NET 2.0 class: Personalizable, WebBrowsable(True), and WebDisplayName. The most likely cause is one or more of these attributes are missing.

Q: Is there a detailed listing published some where that shows how to deploy a WebPart on SharePoint?
A: Yes. I wrote an article titled “Deliver Web Parts with Solution Packages” that can help.

Q: Why not develop straight ASP.NET web parts and use SharePoint web services for data access?
A: Because the SharePoint Object Model is much easier to use and is much richer than the web service model. Additionally, web services do not perform as well as direct object model calls – not just in SharePoint but in any application.

Q: How easy is it to access SharePoint objects such as lists and document libraries?
A: Very easy, that was the subject of the next web cast: Data Lists

Q: Are there limitations to creating a Web Part in SharePoint Designer vs. Visual Studio 2005?
A: You can’t actually create web parts with SharePoint Designer. You can create instances of the Data View Web Part and configure instances of the ListView web part – but you’re not actually developing or creating any new web parts.

Q: Can an existing SharePoint web part be used outside of a SharePoint environment on a public web site?
A: No, they all have a reference to Microsoft.SharePoint.dll which is only available on a SharePoint Server.

Q: What is the process to deploy a solution to a production environment after you are done developing on a developer workstation?
A: Deliver the .WSP (SharePoint Solution) file to the infrastructure team. They can add the solution to the SharePoint solution store with STSADM –o addsolution –filename mysolution.wsp (where mysolution.wsp is the name of your solution file.) Once it’s added they can deploy via the central administration operations section’s solutions management page or via STSADM –o deploysolution.

Q: Are there deployment issues when developing a WebPart that leverages code from a separate assembly? (e.g. a common library used for other applications as well as the web part?)
A: No. Just make sure to include the assembly in the WSP (SharePoint Solution) package.

Q: If a WebPart generates an error – can you have a different WebPart show in it’s place?
A: Not directly, ideally the WebPart will gracefully handle errors.

Q: Can I use a Silverlight WebPart?
A: Yes, Andrew Connell shows how to do this in his web cast.

Q: Is there a way to change how SharePoint treats/stores custom properties?
A: Absolutely. In the custom part of the presentation I showed GetEditorParts(). If you look at the EditorPart interface you’ll see methods to override how the editor part serializes data?

Q: Since the ListViewWebPart is sealed and therefore cannot be inherited, is there another way to get the out of box ListViewWebPart Ajaxified?
A: There are various techniques, however, writing your own vs. relying on ListViewWebPart might be well advised. It’s pretty much my least favorite web part due to “issues.”

Q: Do you have a suggestion for the steps you should take when you need to create a database to support your web part?
A: See the Data Lists webcast.

Q: When starting with SharePoint should you start with Windows SharePoint Services (WSS) or Microsoft Office SharePoint Server (MOSS)?
A: Most development is done against WSS. So it’s a good starting point – however, migrating from WSS to MOSS is easy.

Q: You can simulate the SPListViewWebPart using SPList/SPView.RenderAsHtml methods. These return HTML similar to what the WebPart does. Just set the properties or pass a query.
A: I don’t recommend the use of Render … in any form. Although technically possible, there are limitations around event/click handling that are difficult to work around.

Q: What strategies are available for versioning web parts where the schema of the underlying list has changed?
A: There are a myriad of different strategies here. I recommend that you have a feature receiver make the changes to the schema for you – or that you have the WebPart itself ensure the schema is correct.

Data Lists

Q: Can you tell us when the code from today’s and yesterday’s webcasts will be available and where it will be located?
A: mssharepointdeveloper.com It was also posted at http://www.microsoft.com/downloads/details.aspx?FamilyID=25f9cc59-4ea3-4381-8b37-9430f664eac6&displaylang=en if you want to get it before it’s available on mssharepointdeveloper.com

Q: Is there a recording and a powerpoint available from the previous WebPart webcast?
A: The same links that you used to register for the event will take you to the recorded version including the powerpoints. If you want the power point files, the transcription, and the source code files (but not the recording) you can go to http://www.microsoft.com/downloads/details.aspx?FamilyID=25f9cc59-4ea3-4381-8b37-9430f664eac6&displaylang=en

Q: Will you be able to address using a SharePoint list to accomplish a one-to-many relationship?
A: Out of the box SharePoint lists don’t provide the same relational context as a SQL based relational database. SharePoint lists work best where referential integrity is not a primary concern and code can be used to manage relationships.

Q: Can we refresh a SharePoint List with a SQL Table?
A: Access 2007 can natively write to both SQL and SharePoint. It can be used to refresh data in a SharePoint list. However, it may not be best to think of SharePoint as a shadow copy of a live database.

Q: Since a document library is a kind of list, can I turn on check in/check out on a list?
A: No, the semantics for a list item vs. an item (file) in a document library are different. However, you could create a dummy document and use the metadata on the document library with the check in/check out symantics.

Q: How can we get a SharePoint list to function similar to Intuit Quickbase?
A: I don’t know Intuit Quickbase and therefore don’t know what functionality you’re talking about?

Q: I am having a problem with the “Save As” feature that was mentioned in the presentation. Can you point me to documentation on troubleshooting the “Save As” Feature?
A: F1 – Word Help should be able to get you to the right documentation. From your question it’s not clear what the problem is.

Q: What’s the link for Managing Enterprise Metadata with Content Types?
A: (Thanks Paul Andrew) http://technet.microsoft.com/en-us/library/cc262729.aspx

Q: What are the major differences between a SharePoint List and a SharePoint Document Library? At the core is a SharePoint Document Library also a list?
A: Exactly. A Document library is fundamentally a list that always has one and only one attachment to the item.

Q: What level of this hierarchy is Shared Services at?
A: Shared Services is a web application.

Q: Is it easier to build a list from the UI or from SharePoint Designer?
A: I always build them from the Web UI … mainly so I don’t have to start up another program.

Q: [Statement] IDisposable cannot be used on the current site.
A: It’s true that you should not call the Dispose() method on a SPSite or SPWeb object you get from SPContext.Current.Site or SPContext.Current.Web. However, if you create the SPSite or SPWeb object yourself you should still dispose it.

Q: Is there a way to know the internal name of the field if it was renamed subsequently? Can I do it without writing custom code?
A: Yes, go to the List Settings. Click on one of the fields in the list. The final parameter in the QueryString is Field. This is the internal name of the field.

Q: Are you going to talk about LINQ to SharePoint at all?
A: No, those are community projects and are not required to work with list data in SharePoint.

Q: Is there a way to share a data list between multiple sites?
A: No. However, you can display the data from one site in three different sites – if you configure a DataView web part correctly.

Q: Can you move documents between different SPWebs and SPSites and retain the information about the author, timestamp, etc?
A: Yes, see SPFileCollection.Add() in the SDK.

Q: Can you move a folder with content from one document library to another document library?
A: Through the user interface yes. Through custom code yes. As a single method call in the API, no.

Q: Can we use VB.NET instead of C#?
A: Yes, VB.NET is supported. I just code quicker in C#.

Q: Is there sample code for accessing lists across site collections in the same farm?
A: Not per se. However, you can construct your own SPSite object (new SPSite(url)) and that will give you access to another site collection on the farm.

Q: Do you recommend using the out of box new, display, and edit forms?
A: 90+% of the time I use the out of the box forms because they are easy. Sometimes users need/want more control and therefore write custom pages.

Q: Are there any good references for CAML Syntax?
A: Yes, in the SDK CAML is well covered.

Q: How can you import a SPList using web services since they don’t support a collection?
A: Actually, you can send a batch of transactions. The syntax of the web services is documented – although somewhat minimally.

Q: For your “Copy and Move” web part, why did you call CreateChildControls in your btnMove_Click event handler?
A: Because after a move the files available in the source library changes. However, I’ve already drawn the interface. My CreateChildControls clears the control tree and starts over – so I can just call it again to force the display to be regenerated. It’s a quick hack to make the demo easier to read without a ton of code to handle reprocessing for items changed in the event handlers.

Q: How does ASP.NET viewstate work when you are dynamically adding child controls to your WebPart?
A: This is pretty out of scope for this talk. The short is that the general presumption is that the control tree will match the last time it was drawn. However, I do not recommend the use of view state.

Q: Are there any concerns with developing custom code within SharePoint – or should we use the web services instead?
A: If you use the well defined interfaces, you shouldn’t have problems upgrading. Using web services won’t really help that much. (if at all).

Q: Does WSS allow “Uplaod Multiple Documents” or is that only in MOSS?
A: The demo VPC is WSS only – Upload Multiple Documents is in WSS. You must have client integration turned on for it to work and you must be running IE.

Q: What are some of the potential cause for a list template not showing custom forms?
A: If the forms aren’t present SharePoint will revert back to the out of box forms. It’s most likely that the form didn’t get deployed.

Q: Is there a way to have multiple documents in the same record?
A: No, however, you can create a separate folder for each record or use a list item and attach the documents to the list item.

Q: Where can I find out how to work with the attachments of a list item?
A: The Attachments property as documented in the SDK is a good place to start.

Q: How do picture libraries and forms libraries differ from a document library and other lists?
A: Picture libraries offer thumbnails which document libraries don’t have. Forms libraries offer the summarization of data that document libraries don’t offer. Otherwise they’re the same

Q: Is there a way to have the same slide deck in multiple places in a slide library?
A: Not to my knowledge.

Q: How is security on the list applied to a web part’s operations?
A: The web part’s operations are by default in the context of the user. Thus a web part cannot do something a user can’t do – except if the WebPart author uses a special API to get elevated priviledges.

Q: Can we update the “User Information” list programmatically?
A: Yes, look at SPSite.AllUsers.

Q: How do you restrict viewing certain list columns programmatically?
A: You can’t really do that. There are some hacks but fundamentally column level security isn’t supported.

Q: Can I show different forms to different users on the same list?
A: No, but you can make your custom forms intelligent enough to display a different user interface to users. However, it would technically be the same form.

Q: Can we have a SharePoint Document Library attached to an item of a list?
A: No, but you can have a URL pointing to a document library as a field in the list.

Q: Should we use the internal field names or display names in CAML Queries?
A: Always, internal names. CAML gives you some ugly/bad messages if you try to use display names.

Q: Can lists contain child lists?
A: No, but you can have folders in lists.

trapped in computer

Be an Expert (Or Play One on TV) – With SharePoint Introduction Webcast Materials

I’ve posted previously about the web casts that Andrew Connell and I are doing. I’m happy to announce that the materials that Andrew and I are using for these web casts are now available for everyone. Not only do you get the source code but you’ve got the slide decks as well (including a transcription of the web cast in the notes.)

Sidebar: We’re aware that the demos for my first two recordings are REALLY small. It looked fine when they were live. I’ll rerecord them in the next few weeks and will make a post to let you know that they’re fixed. Thanks for your patience.

machine

How Best Are Your Best Practices

In my work with Andrew Connell on the Web Casts for Paul Andrew, we’ve been struggling to make sure that what we’re delivering in the web casts and in the hands on labs that will accompany them represents state of the art best practices. It surfaces in tons of little ways. For instance, you should always dispose SPSite and SPWeb objects you create yourself (and not those you get from SPContext.Current) so the sample code has using statements in it to make sure that the objects are properly disposed. We’ve also religiously defended against the possibility of using Render() or RenderContents() in a web part as dozens of demos have done. Why? Well, because there’s a consensus around using CreateChildControls(). The reasons are somewhat simple – because ASP.NET can work with CreateChildControls() to change the display for alternate devices (via ControlAdapters), post back values and event firing works, etc. Basically it’s a well behaved member of the family where as render and render contents are more ASP-Classic in their approach where you just write whatever you want.

Those are some of the easier ones to put a stake in the ground on. They’ve got clear cut advantages, disadvantages, and enough people willing to stand up for them. There are more subtle things that we’ve been defending as well. Things like building web parts instead of web pages in SharePoint – because the platform is about modular, reusable UIs. However, my point here isn’t to enumerate all of the things that I think are – or should be best practices. The point is that I think there’s a natural problem that we have in the industry that everyone needs to help solve. (Yes, I mean you reading this right now.)

First, let me quote James Bach who was speaking about software development methodologies “There is no consensus about what practices are best, unless consensus means ‘people I respect also say they like it.'” I believe our situation with SharePoint is not all that different. We’ve got a handful (or more) opinions about what a best practice is but little consensus on what the best practice is. I think that this is because that there isn’t one perfect answer. There isn’t in anything else either. We have suspension bridges, cable-stayed bridges, arch bridges, etc. Not one kind of bridge fits all. They each have different benefits. So while I can pretty definitively call out CreateChildControls() as a best practice, I find it much harder to persuade Todd Bleeker that my configuration based approach to loading user controls is better than his integrated project approach. I think that both can be best practices in the space. (I know I haven’t defined the details of the approach, ignore that for now, it’s not important to this discussion.)

However, there’s another problem – one that in my opinion is much more insidious. There’s a large gap between the State of the Art and in the State of the Industry. In other words, we know what to do but we don’t do it. I’ve been talking about this problem in the software development space for a long time. However, I think that the problem might actually be worse in the SharePoint space. A buddy of mine, Shane Young, recently posted a blog entry — What makes a “good” SharePoint Consultant. One of the things he is saying without directly saying is that he gets called in, like I do, to clean up a ton of messes that some SharePoint consultants are creating because – in this case – they don’t know what the product can do out of the box. I wish I could make as bold of statements as Shane can about needing to know a lot about SharePoint before doing any work on the platform. I can’t because it seems like I am still learning something new about SharePoint every week – given the amount of experience I’ve got, the problems I’ve solved, and the solutions I’ve created – that shouldn’t be the case but it is. I say shouldn’t because at some point you should know everything about a system. However, I’m realizing that it’s bigger than any one person (or team of people) can experience.

Back to my point, there’s a large gap between what we know to do and what we actually do. Ben Curry just posted a blog entry about quick performance tips for SharePoint. Most of us know that these are best practices, but how many of us do them when we setup a new server? My observation is very few. Ben and Bill have gathered a whole set of these Best Practices into a book Microsoft Office SharePoint Server 2007 Best Practices that will be out soon. Will their best practices be the best practices – or merely a best practice? I suspect a bit of both. However, knowing what to do as someone might after reading the book is only half the battle. When are we going to actually do what we say?

Need another example? How about the SharePoint Governance Checklist guide that Joel Oleson distilled from my SharePoint Governance articles (Part 1 and Part 2) and then added some additional content to? How many take the 20 minutes it takes to get through this content and answer the important questions that are raised? In my observation, very few folks – even those that know about the materials – actually take the time to ask the questions and figure out the answers before implementing SharePoint.

Another thing (besides Ben and Bill’s book that’s focused on infrastructure) that may help drive us to the right place is the work that the Patterns and Practices team at Microsoft is embarking on now. Glenn Block posted on his blog that they’re looking for feedback. They’re trying to understand how people develop with SharePoint so they can provide some direction. They’ve put together a survey to try to get that feedback.

My only hope is that we can all settle on a set of best practices and actually start to use them.

Article: Office Space – From VBA Macro to Word Add-In

Document automation isn’t a new functionality by any means. It has been going on since the invention of macros, and there has been a full-fledged programming model within Microsoft® Office applications since the early 1990s. For many years, the Office tools have featured macro recorders that weren’t limited to simply replaying keystrokes but have been capable of writing code on the fly as well. Macros have even demonstrated that they are functional enough to write viruses. And while writing a virus using a Word macro may be a dubious feat, it is a feat nonetheless.
However, even with all of the capabilities of Visual Basic® for Applications (VBA), there are some things it just doesn’t do very well. In the early days of VBA, XML hadn’t yet been invented, the Internet was in its infancy, and the first HTML pages were just beginning to appear. As such, it’s no wonder that making a Web service call isn’t well handled in the context of Visual Basic for Applications.
The Microsoft .NET Framework CLR, on the other hand, understands these technologies quite well. The ability to call Web services is just one among a number of reasons for wanting to write .NET-targeted code rather than VBA—and doing so means using Visual Studio® Tools for Office (VSTO). But switching from VBA to VSTO doesn’t have to be a case of throwing the baby out with the bath water; rather, it can be just a natural way to extend how you are already developing solutions in Office.
In this column you’ll see how to use Word to capture some VBA code that solves a basic problem. Then I will use the latest version of VSTO included with Visual Studio 2008 to wrap this code into a deployable Word add-in. I’ll also write some simple code for some of the tasks that the macro recorder either just can’t record or doesn’t record in an optimal way.
http://msdn.microsoft.com/en-us/magazine/cc507643.aspx [Article removed]

Recent Posts

Public Speaking