Posts

Showing posts with the label Sharepoint

c# script to delete very large second stage recycle bin items in sharepoint 2007

In SharePoint 2007, when item versioning is set to no limit for a document library, you could easily have a spiraling content database size.  When you try delete a ginormous item, it'll eventually get stuck in the second stage recycle bin, and you'll never be able to reclaim that database space or file space - a forced purging of the recycle bins through a UI operation will time out eventually, rolling back a huge transaction, probably freezing the site for your users - cue fire and brimstone. The solution is to run the following script off-hours.  Off hours helps minimize any potential blocks SQL server may issue against database pages as it goes around deleting the row content from alldocversions - from what I can tell, many I/O Page Latch locks are issued when SQL is deleting blobs, so to be nice to this script and run it off hours.  Compile it into a c# console application referencing the sharepoint dll. There isn't much for progress reporting included in the script...

sharepoint trick to edit "new item form" by adding to url

Image
Hide columns on NewForm, DispForm, EditForm in SharePoint list To remove columns from appearing on a display, edit item, and new item form in SharePoint lists, e.g.: The goal is to add some JavaScript into a Content Editor Web Part (CEWP) on the above page. To add web parts to any page within Sharepoint : On the URL of the form page you are, add to the end of it: &toolpaneview=2 (i.e. Or remove all the stuff (querystring) stuff at the end of URL and change it to DispForm.aspx?toolpaneview=2 . The page will then change to Edit Mode: From here, add a CEWP, content editor web part, to the page UNDER the form already on the page. This is very important, if will not work if the CEWP is not under the form. Modify the CEWP, open the source editor, and paste in: <script type="text/javascript"> var containers = document.getElementsByTagName("*"); for (var i=0;i<containers.length;i++) { if (containers[i].innerText == ...

Win 7 & SharePoint fix: webdav Explorer (windows explorer view's) slow performances issue

Since upgrading any client to Windows 7, SharePoint's Windows Explorer view got really really slow. Guess what, it has to do with IE 8's (maybe IE7 too) automatic proxy detection, not SharePoint.  You might experience this slowness connecting to any webdav server, including my iPhone's. Here is the fix: In Internet Explorer, open the Tools menu, then click Internet Options. Select the Connections tab. Click the LAN Settings button. Uncheck the “Automatically detect settings” box. Click OK and thank daniel cd  http://social.technet.microsoft.com/Forums/en-US/w7itpronetworking/thread/600a9825-0ba1-4c15-93f6-fc99c64b4930 or chief oddball  http://oddballupdate.com/2009/12/18/fix-slow-webdav-performance-in-windows-7/

Locking down Actions in SharePoint 2007 like Edit in Datasheet, Export to Spreadsheet

Image
Among the many requests we get to compose or decompose some of the basic functionality built into SharePoint 2007 - we get this one a lot.  For some very valid business reasons, Edit in Datasheet or Export to Spreadsheet (Excel / Access) violate some of the metadata rules or workflow customizations that may affect metadata.  I think this is due to the lack of robust field level security tied out to the users or groups in SharePoint.  It's not too hard to build this into SharePoint (most serious web applications have field level security), and I've even helped build field level security into a few widely employed web applications. So maybe its due to something else.  Either way, to disable the functionality, you basically gut SharePoint's webservices from the set of users you want to lock it down for. Go to [your site] > Site Settings > Permissions > Permission Levels Note: to do this for a single list, break permission inheritance at the list, th...

Upgrading custom sharepoint 2007 workflows in progress

From what research I've done, it seems safe to upgrade (via solution deployment) previously associated, deployed, and running SharePoint 2007 Custom Workflows (developed in Visual Studio) that are In Progress. The two key areas why I think this works is to do with the content that SharePoint hydrates each time a workflow moves into and out of memory.  In old-fashioned programmer speak, the program section and data section are saved with each instance of a workflow.  In current lingo, I understand Extensible Application Markup Language (XAML) is used to represent SharePoint workflow objects in XML thereby allowing the instances of all the data objects and the program code to be streamed into and out of memory in perpetuity.  If you think about how challenging this is to accomplish, you'll understand why I really respect this aspect of SharePoint, and how it adds to the awesomeness of skill displayed by their development team.  Caveat emptor: dehydration and r...

SharePoint 2007 URL Quick List still holds up

I think its funny/slightly sad that very little about this list of URLs have changed since Heather Solomon wrote this information up  in July 2005 - 4.5 years later; this is a relevant and useful administrative list of URLs that are sometimes hidden depending on a few factors in your deployment: Portal and WSS Function Add to the URL Notes Manage List Template Gallery /_catalogs/lt/Forms/AllItems.aspx Manage Site Collection Users /_layouts/1033/siteusrs.aspx To access you must be an admin on the server or a site collection admin for the site. Manage Site Groups /_layouts/1033/role.aspx Manage Users /_layouts/1033/user.aspx Manage Web Part Gallery /_catalogs/wp/Forms/AllItems.aspx Site Usage Report /_layouts/1033/UsageDetails.aspx Site Usage Summary /_layouts/1033/Usage.aspx User Information /_layouts/1033/userinfo.aspx Web Parts Maintenance Page ?contents=1 Add to the end of the page URL Portal Only Function Add to the URL Notes ...

SharePoint Jokes

What do you call a smiling, SOBER courteous person at a SharePoint conference? A: The caterer. Light travels faster than sound. This is why some SharePoint consultants appear bright until you hear them speak. A good SharePoint consultant is someone who can tell you to go to hell in such a way that you look forward to the trip. How many SharePoint consultants does it take to screw in a light bulb? How many can you afford? I always take SharePoint with a grain of salt, ...plus a slice of lemon, ...and a shot of tequila. Client says to SharePoint consultant - Well aren't you a waste of two billion years of evolution. SharePoint: working daily to make the human brain obsolete. I told my boss that everyone hates SharePoint. He said I was being ridiculous… everyone hasn't used it yet. SharePoint work is something you do that nobody notices until you don't do it. Top three things SharePoint Consultant won't say: You're right; we're billing way too much for...

wspbuilder error "Could not load file or assembly 'CabLib, Version=6.9.26.0, Culture=neutral, PublicKeyToken=85376ef9a48d191a' or one of its dependencies. An attempt was made to load a program with an incorrect format."

I really love when a fix is simple. Back story : in this case, I am in the midst of using a combination of wspbuilder and spsource to reverse engineer, package up and deploy a few custom content types. wspbuilder is a codeplex Visual Studio extension that helps package up SharePoint code into a Solution file (WSP) for deployment. spsource is another tool that tries to analyse a SharePoint site and tease out a schema.xml for a list, and column & field information for a content type.  I use the term 'tries' because depending on how clean your dev environment is, your mileage may vary.  Problem description : when running WSPBuilder -> Build WSP, the output window in Visual Studio says Could not load file or assembly 'CabLib, Version=6.9.26.0, Culture=neutral, PublicKeyToken=85376ef9a48d191a' or one of its dependencies. An attempt was made to load a program with an incorrect format. It is my belief this problem is related to the installer not detecting/s...

Displaying workflow item information from a custom ASPX task form

When building custom workflows, often we want custom Task edit screens as well.  A custom Task Content Type allows us to collect much deeper data than 'completed'.  However, since we are ditching the default Task edit pages, we lose a couple of useful features; a link to the underlying Workflow item as well as the implied context of the Task. Given the need to provide context to the user when overrriding the default task form, you may come across the desire to display some file information, custom columns/properties, links, etc on the task edit page.   To accomplish this, we need to gain two pieces of understanding: How and when to modify ASPX page elements from the code-behind c# class How to extract the underlying information from the Workflow's original item When: during the page_load() of inherited class; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ...

Security and Audit Trail of Workflow Tasks in SharePoint 2007 & Visual Studio 2008

Image
Two requests that are probably part of every SharePoint workflow design: Permit only the users who are assigned a WF tasks to edit (i.e. complete) them Record the user name of the person who completes a task (instead of the System Account) Not suprisingly, neither of these pretty simple, seemingly obvious design concepts can be done out of the box / without some customization.  Also, certain configuration screens might trick you into thinking you can do this directly within the SharePoint UI (you can't; more on this in the deeper blog posts). Part 1: Security of Workflow Tasks in SharePoint 2007 and Visual Studio 2008 Part 2: Audit Trail of Workflow Tasks in SharePoint 2007 and Visual Studio 2008   There are a couple of good blog sources for each of these customizations, but I didn't find any of them to be thoroughly detailed with screenshots, pitfalls, etc.  So what I hope to do in this two part blog post is cover some portions I think those...

Workflow LogToHistoryList UserID and Task Activity Executor in SharePoint

Image
This topic is within a SharePoint 2007 workflow, how do we get the Workflow History to reflect the user who modified a task, rather than the "System Account".  I've successfully implemented the solution suggested by Julie Kramer , from the office dev blog.  Here we go: snippet of a workflow design in VS2008 - focus on the two red activities Assign a new field to the Executor property of the OnTaskChanged activity in question (you'll see this property in the property window on the activity). Note we use this new field in a later LogToHistoryListActivity's Method_Invoking() by assigning the UserID property of the LogToHistoryListActivity's object Add a userid lookup/helper function to guarantee a valid SharePoint user id is in place private SPUser GetUserObject(string accountID) { try { if (accountID.IndexOf(@"\") > 0) { SPUser use...

SharePoint vs. File Servers

Whenever you talk to someone about the document management features of SharePoint, the question comes up; how does one differentiate and create guidance around when to use a file share versus when to use a SharePoint Document Library.  There are many levels of appreciation of SharePoint's feature set - and kind of like an onion, there are many things that are underneath the surface.  Here are some examples of features that are difficult to implement on a file share: commented version history file metadata / content classification audit tracking data retention policy implementation / enforcement self-service recoverability business processes / workflow Moreover, below are some examples of when to use a file share over SharePoint: audio streaming or video streaming product distribution server & desktop backups Access database storage custom tools distribution, utility executable distribution, script distribution archive file storage Table: Simplified Comp...

Searching your SharePoint sites with Internet Explorer 8

IE8 follows the FF path and has a customizable Search Toolbar that can be plugged into a SharePoint instance. Start by clicking on the “Find More Providers” menu item on the drop down in the IE8 search toolbar area. On the bottom of the Providers screen you can find a link: “ Create your own Search Provider ”. So if you want to add your SharePoint search page to the IE toolbar, follow the on-screen directions; enter SharePoint search result URL after typing TEST - e.g. http://intranet/search/Pages/results.aspx?k=TEST . Now you’re able to use your SharePoint search site directly from your browser credits: this post is nearly verbatim from this blog

"Failed on Start (retrying)," said the workflow

Image
Seemingly inexplicably, SharePoint will less than always cooperate. In this case, it happened after a major round of refactoring custom workflow solutions, but ULS logs and other debugging techniques were proving fruitless. After going through the various debugging tips posted on various blogs such as: http://blogs.msdn.com/wael/archive/2008/01/11/workflow-failed-on-start-retrying.aspx I found the solution was don't refactor so deeply, or really know when an XML attribute is referring to a library.classname or namespace.classname (OUCH, the subtlety). e.g. in my case, workflow.xml's attribute for CodeBesideClass = "unbudgetedBI_InitialApprovalWF.Workflow1" then the workflow project (called "unbudgetedBI_InitialApprovalWF") has a workflow file called "initialapproval.cs" (with corresponding .rules and .desiginer.cs). Within this c# file is the namespace "unbudgetedBI_InitialApprovalWF" and a public class "Workflow1". When trying ...

the PeopleEditor and how Validation sucks in SharePoint

Just over another hurdle in the SharePoint steeplechase. This one involves the glorious PeopleEditor control and how to make sure the user has some client-side feedback before they post their selection. Through the nest of blogs and comments about the general ASP.NET versus the universe of SharePoint problem, the best solution seems to revolve around hacking the client side javascript and doing the most manual processes imaginable to get consistent validation. Precisely, I mean that within the PeopleEditor should support simple validation out of the gate, but the AllowEmpty property doesn't work (see Karine Bosch’s comments from this blog link ). Then you end up going through the following failure steps before the aforementioned hack emerges as the winner: AllowEmpty property of PeopleEditor (Karine Bosch’s link ) #FAIL ValidatorEnabled property of PeopleEditor (Karine Bosch’s link ) #FAIL Adding the ASP.NET RequiredFieldValidator element within the ASP form (shereen's bl...

The e-mail message cannot be sent. Make sure the outgoing e-mail setting for the server are configured correctly

It seems like there are hundreds or thousands of people out there that have come across this little SharePoint sendemail bug. Beware this error message is a red herring! My suspicion is that through a series of unfortunate events around the sequencing / pipelining of workflow activities, the sendmail activity gets terminated prior to having a chance to become a fully dehydrated object. Postulations aside, here is the fix I used: Observation 1 from 12's hive logs (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS): w3wp.exe (..) 0x.. Windows SharePoint Services, General, 8kh7, High, Cannot complete this action. Please try again. Observation 2 from Workflow History: Error, System Account, The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly. So I fixed my <sendmailobject>_MethodInvoking by binding the sendmail activity's email fields (to:, cc:, body:, etc) to class variables and then ass...

Workflow History versus Audit Trail

MOSS removes the association between workflow tasks, history items and the workflow 60 days after the workflow has been completed through the workflow cleanup timer job for performance reasons. Consider this next suggestion a workaround for that bad design; most companies that develop custom workflows will want that history around for some time. Several alternatives are available, albeit brute-force methods, but the one I elected to go with is to place the following bit of configuration in the workflow.xml prior to associating a workflow. workflow.xml <Elements> <Workflow> .. <MetaData> <AutoCleanupDays>9999</AutoCleanupDays> </MetaData> .. See Brian Farnhill for more documention on this issue.

secret lengths of OnBehalfReason

As I was setting up a custom SharePoint workflow to work with an external user outside of the domain, I noticed some quirky behavior and error messaging from SharePoint. e.g. it works if its a short piece of text like the MOSS 2007 SDK: createPartnerReviewTask_TaskProperties1.OnBehalfEmail = "null@void.com"; createPartnerReviewTask_TaskProperties1.OnBehalfReason = "This user does not have access to this Windows SharePoint Server site."; but dies like this when its too long: WinWF Internal Error, terminating workflow Id# 7c4d... System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties.set_OnBehalfReason(String value) what range is specified in the reference? undocumented.

the lie: Workflow Error: System.InvalidOperationException and the Correlation Token

Whenever I get an error in the pile of logs that is SharePoint Workflow, I have to wonder how this made it through QA. Case and point: a message that returned when executing a CompleteTask activity within a workflow: System.InvalidOperationException: Correlation value specified does not match the already initialized correlation value on declaration for activity . This should equate to - check the correlation token you set, logically. It even seems like this is a logical conclusion from the top of procedure stack; at ..CorrelationService.ValidateCorrelation() at ..CorrelationService.InvalidateCorrelationToken() .. But no, what it actually means is check the Taskid properties . Figured out with the blog entry by Andy Burns .
Following Robert Shelton's well documented series on creating MOSS 2007 workflows in Visual Studio 2008, I ran across a bit of a snafu. Basically, his recommended dev machine setup stipulates WSS3, VS2008, etc. However the Visual Studio 2008 wizards/templates for Sequential Workflow expect MOSS, not WSS. The workaround should get me positioned to develop, debug, package and deploy workflows in VS2008. I found the most complete workaround write-up on this issue on the Visual Studio SharePoint Tools Blog by Roger Best. Here is his writeup in full (in case the link stops working one day..) "Getting Visual Studio 2008 SharePoint 2007 Sequential / State Machine Workflow projects working with Windows SharePoint Services 3.0 Published 19 August 08 02:18 PM I wanted to create a SharePoint workflow using VS 2008 on WSS 3.0. The documentation is set that only Microsoft Office SharePoint Server 2007 can be used but I figured I would lay out the modifications needed to allow a pro...