SnTT: Unlink individual design elements from a template
By request, here's a SnTT (whoa, it's actually Thursday for once) demonstrating how to programmatically unlink any design elements tied to a specific template (while leaving intact any other element-level inheritance):
Public Function UnlinkElements(dbTarget As NotesDatabase, Byval templateName As String)
Dim linkedElements As NotesNoteCollection
Dim element As NotesDocument
Dim noteId As String
Set linkedElements = dbTarget.CreateNoteCollection(False)
Call linkedElements.SelectAllDesignElements(True)
Let linkedElements.SelectionFormula = {$Class = "} & templateName & {"}
Call linkedElements.BuildCollection()
If (linkedElements.Count > 0) Then
Let noteId = linkedElements.GetFirstNoteId()
While (Len(noteId) > 0)
Set element = dbTarget.GetDocumentByID(noteId)
Call element.RemoveItem("$Class")
Call element.Sign()
Call element.Save(True, True, True)
Let noteId = linkedElements.GetNextNoteId(noteId)
Wend
End If
End Function
Enjoy...








Comments
At the least, check whether the original item is signed, and only update the signature if it was.
Posted by Andre Guirard At 21:44:11 On 02/14/2008 | - Website - |
Posted by Tim Tripcony At 00:19:30 On 02/15/2008 | - Website - |
Posted by Chris Whisonant At 13:25:43 On 02/15/2008 | - Website - |
{ Link }
I think it's in my trunk.
Posted by Tim Tripcony At 13:53:23 On 02/15/2008 | - Website - |