Home > Domino Tips > Developer > Move folders from one Notes database to another using a LotusScript agent
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Move folders from one Notes database to another using a LotusScript agent


Marko Bonaci
04.27.2006
Rating: -3.94- (out of 5)


Lotus Notes, Domino, Workplace and WebSphere tips and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


VIEW MEMBER FEEDACK TO THIS TIP

When you run the LotusScript code below, it will ask you which folders you want to move from a current Notes/Domino database and to which database you want them moved.

Sub Initialize
    Dim s As New NotesSession
    Dim w As New NotesUIWorkspace
    Dim dbSource As NotesDatabase, dbDest As NotesDatabase
    Dim source As NotesView, dest As NotesView
    Dim vc As NotesViewEntryCollection
    Dim docDest As NotesDocument
    Dim ve As NotesViewEntry
    Dim folders() As String
    Dim i As Integer
    Dim ret, rez
    
    Set dbSource = s.CurrentDatabase
    
    Forall v In dbSource.Views
        If v.IsFolder Then
            i = i + 1
            Redim Preserve folders( i - 1 ) As String
            folders( i - 1 ) = v.Name
        End If
    End Forall
    
    ret = w.Prompt( PROMPT_OKCANCELLISTMULT, "Folder selection", 
"Select one or more folders to move.", folders(0), folders )
    If Isempty( ret ) Then 
        Messagebox "User canceled", , "Folder not selected" 
        Exit Sub
    Else
        Forall f In ret    
            Set source = dbSource.GetView( f )
            Set vc = source.AllEntries
            
            rez = w.Prompt( 13, "Database selection", 
"Choose the database to move the folder to" )
            If Isempty( rez ) Then Messagebox "User canceled", , 
"Database not selected" : Exit Sub
            
            Set dbDest = s.GetDatabase( rez(0), rez(1), False )
            Call dbDest.EnableFolder( f )
            
            Set ve = vc.GetFirstEntry
            Do Until ve Is Nothing
                Set docDest = ve.Document.CopyToDatabase( dbDest )
                Call docDest.PutInFolder( f )
                Set ve = vc.GetNextEntry( ve )
            Loop
            
            Call vc.RemoveAllFromFolder( f )
            Call source.Remove
        End Forall
    End If
End Sub


MEMBER FEEDBACK TO THIS TIP

Here's a quick add-on that will allow you to copy the design of the folder as well.

Sub Initialize
...<snip> ...
'Code added
Dim col As NotesViewColumn

... <snip> ...
Set dbDest = s.GetDatabase
( rez(0), rez(1), False )
Call dbDest.EnableFolder( f )

'Code added
Set dest = dbDest.GetView( f )

'Copy the columns from the 
source to the destination folder 
While dest.ColumnCount > 0
Call dest.RemoveColumn(dest.ColumnCount)
Wend
For i = 0 To source.ColumnCount-1
Set col = dest.CopyColumn(source.Columns(i), i+1) 
Next

'Code added
... <snip> ...

End Sub

—Raimund G.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Marko Bonaci. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Agent
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax
How to automatically create a backup copy of your Domino Directory
Export Lotus Notes documents to Microsoft Word via Internet Explorer
A bevy of Notes/Domino development tips
Best practices for using the Lotus Notes WebQuerySave agent

LotusScript
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database

Lotus Notes Domino Agents
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
Top 10 Lotus Notes Domino programming and development tips of 2007
How to export data from a Lotus Notes database to a CSV file
Must-know Lotus Notes Domino agents -- 10 tips in 10 minutes
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax
Troubleshooting a scheduled agent not running on a Global Notes Architecture (GNA) server
Can I stop Lotus Domino Server from transforming embedded images into attachments?

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts