Supporters of End User
Web

QOTD: SharePoint Document Library

Item is currently unrated. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.
Categories:MOSS; WSS; 2007; 2010; Question of the Day; Content Types; Out of the Box; SharePoint Designer; Workflow; Solutions with Tools

Author: Eric Alexander, Moderator, Stump the Panel

The Question of the Day from Stump the Panel came in regarding document libraries in SharePoint:

Wendy writes:

I have a document library that I created to share files with clients that are too large to e-mail. It will never be used for long-term storage, and I don't want the files in it to get forgotten and take up valuable storage space, so I would like to set up some kind of workflow that will automatically delete a folder and all files within it two weeks after creation. Here are the restrictions I am working within:

  • I would like to avoid using SPD if possible (our SP support team has said they won't fix anything broken if we have ever touched our site with SPD)
  • I would ideally like to be able to delete an entire folder and its contents, not just individual files
  • We already have corporate-defined document retention policies set up for us, so I can't handle this that way
  • We have MOSS 2007

Any thoughts?

Thanks!

Wendy -- STP

-------------

Both Kerri and I agree that the only out of the box option to automate the process is to use Information Policy Management within the document library leveraging content types for folders and documents. The challenge would be if these documents could be exempted from the corporate policy, if they cannot, then using IRM wouldn’t work. If that couldn’t be done, then manual cleanup will be needed.

As a personal aside, when will IT staves get over this whole SPD nonsense? Yes, it has the potential to be damaging, but you do have a backup plan in place right? Limiting the functionality of the product not only reduces end user buy in, but also severely impacts any sort of return on investment. There are tons of resources available for SPD training. Plan, govern, and train and you’ll have happy employees, see adoption increase, and see a larger return on your SharePoint investment.

To set up IRM on the document library:

  1. Go into the document library settings.
  2. From this menu, you'd want to hit the radio button Define a Policy and click OK.
  3. Tick the check box for Enable Expiration.
  4. Set the Time period to Created plus 14 days.
  5. Set the action to Delete.
  6. Click OK.

Matt offers an alternative approach with the Explorer View and a script.

Option Explicit

Const strFrom = "example@domain.com"
Const strTo = "example@domain.com"
Const strMailserver = "smtp.domain.com"
Const strSchema = "http://schemas.microsoft.com/cdo/configuration/"

Dim objFSO, objFolder, objEmail
Dim colFiles
Dim file, Subject, Body, strError

set objFSO = Wscript.CreateObject("scripting.FileSystemObject")
set objFolder = objFSO.GetFolder("\\server\share")
set colFiles = objFolder.Files

For Each file in colFiles
   If DateDiff("d", file.DateLastModified, Now) >= 14 Then
      ON ERROR RESUME NEXT
      file.Delete
      ON ERROR GOTO 0
      If Err.Number <> 0 Then
         Call ErrHandler("FTP AUTO DELETE FAILED!", "Number = " & err.Number & " Description = " & err.Description & " Source = " & err.Source)
      End If
   End If
Next


Call SendEmail("FTP AUTO DELETE SUCCESSFUL", "All expired files were deleted.")


Sub ErrHandler(Subject, strError)

   err.Clear
   
   Call SendMail(Subject, strError)
End Sub

Sub SendEmail(Subject, Body)
   Set objEmail = CreateObject("CDO.Message")
   objEmail.From = strFrom
   objEmail.To = strTo
   objEmail.Subject = Subject
   objEmail.Textbody = Body
   objEmail.Configuration.Fields.Item _
       (strSchema & "sendusing") = 2
   objEmail.Configuration.Fields.Item _
       (strSchema & "smtpserver") = strMailserver
   objEmail.Configuration.Fields.Item _
       (strSchema & "smtpserverport") = 25
   objEmail.Configuration.Fields.Update
   objEmail.Send

   Call Cleanup
End Sub

Sub Cleanup

   set objFSO = nothing
   set objFolder = nothing
   set objEmail = nothing
   set colFiles = nothing
   set file = nothing
   set Subject = nothing
   Set Body = nothing
   Set strError = nothing
   
   WScript.quit
End Sub

Author: Eric Alexander, Moderator, Stump the Panel

Eric Alexander is a SharePoint Administrator working in the Higher Education sector. He wears many hats in this role and enjoys leveraging SharePoint to build solutions to solve problems across campus. You can find him on Twitter as PirateEric and lurking in the Stump the Panel forums.
http://feeds.feedburner.com/EricsSharepointAdventures

[tweet]

Comments

Notify me of comments to this article

E-mail:
   

Add Comment

Title:

 
Comment:
Email:

   


Name:

 
Url: