Posts

Showing posts from July, 2009

MOSS Workflow History Association

Based on a lot of the blog sites, SharePoint 2007 (MOSS) has a timer job that will purge the workflow history association with the work item after 60 days. For most of the users, this is not a good thing because our their audit depends on it. I have read a few solutions that can work around this issue. Use a custom list for audit and do not depend on the workflow hisory. Based on Microsoft, workflow history is not intended for audit purposes. You should probably always create a separate audit log. You can write code to log your workflow history or events to a separate list. Try to use folder structure (i.e. year, month, workflow ID, etc...) so that you don't have more than 2000 items in a view/folder. Write code to change the default days from 60 to whatever your requirement is. There is a sample code that was posted on one of the comments in this post(http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/b15b27e2-3033-418b-9731-968273d7423e). I have copied and pa...

Close/Open Web Parts Programmatically

I didn't see a lot of post that shows you how to close and open web parts programmatically. I figured I'll writer one just in case I forget how to do it later. You have to work with WebPartManager class for working with web parts. To get the web part manager, you can do the following: SPFile page = site.GetFile("pageUrl") SPLimitedWebPartManager webPartMngr = page.getLimitedWebPartManager(PersonalizationScope.Shared); Once you have the WebPartManager, you can get the web part that you want to close by doing: Foreach (WebPart webPart in webPartMngr.WebParts) { if (webPart.Title == "testWebPart") { webPartMngr.CloseWebPart(webPart); webPartMngr.SaveChanges(webPart); } } The SaveChanges() has to be done else it just won't work. After the web part is closed, you can still find it in webPartMngr.WebParts collection to re-open it. The code is basically the same as how you would close it. Just change the CloseWebPart() to OpenWebPart() instead.