Search

What the Quote?

"There's a light at the end of my carpal tunnel."

Tim Tripcony

"I don't want to shoot the Pope in the eye for a Klondike bar, but anything anything else would be uncivilized."

Steven Rodgers

"It'll be 'The Summer of Jane'. Somehow, 'The Fall of Jane' just doesn't have the same ring to it."

Jane Cook

« Quote of the day | Main| Example of using LS:DO to connect Domino to other systems »

SnTT: Unlink individual design elements from a template

Category show-n-tell thursday
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

Gravatar Image1 - Thanks, Andre, that's good to know. I've gotten in the habit of signing any elements modified via a NotesDocument handle regardless of the modification to avoid the "this document has been modified or corrupted since signed" warning... which goes away, of course, the next time the element is manually saved, but tends to spook some developers. Makes sense in retrospect, though, that this wouldn't be an issue when modifying unsigned items.

Gravatar Image2 - Based on one quick, not conclusive test, the $Class item is not signed. Therefore, it shouldn't be necessary to re-sign the design element. Doing so can complicate matters if the new signature is different.

At the least, check whether the original item is signed, and only update the signature if it was.

Gravatar Image3 - I know... 12 minute TTL? Must be losing my touch. Time to dig out the ol' FrogPad again.

{ Link }

I think it's in my trunk.

Gravatar Image4 - It took you long enough to get this done and posted!! Good grief... Emoticon

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Contact Me

Elsewhere

Assorted Linkage


Locations of visitors to this page