Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminating a field from a document

Status
Not open for further replies.

saecsens

Programmer
Aug 5, 2003
21
CA
I have a document that I have to make a copy off. The new copy will be the same as the old document except that a field must not be copied and it cannot just be hide.
Can somebody help me with that issue ?
 
I can only see one solution, you need to remove the field after copying the document.
Create an agent using formulas, and type in the command
Code:
FIELD name:=@deletefield
.
Then save and run the agent on your document copy. That should do the trick.

Pascal.
 
thx for the awnser ;)
but is there's a way to do the same with LotusScript ?
 
Yep.
Use the notesuidocument, get the backend notesdocument, get the item with doc.getfirstitem and use the Remove method.
Don't forget to save the backend afterwards, else you've accomplished nothing !
 
maybe I'm dumb, but I can't seem to be able to get rid of my field with remove or removeitem methode...


Dim session As New NotesSession

'création des nécessités
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim view As NotesView
Dim docEcran As NotesDocument
'crée un doc vide
Dim db As NotesDatabase
Dim CRPublique As NotesDocument
Dim itemA As NotesItem
Dim itemB As NotesItem
Dim itemC As NotesItem

'copier le document ouvert dans le document vide
Set uidoc = workspace.CurrentDocument
Set docEcran = uidoc.document
Set db = session.currentDatabase
Set view = db.GetView( "vCRrestreint" )
Set CRPublique = New NotesDocument(db)
Set CRPublique = docEcran.CopyToDatabase(db)

Set itemA = CRPublique.GetFirstItem( "type" )
itemA.values = "CompteP"
Set itemB = CRPublique.GetFirstItem( "titre" )
itemB.values = "Compte rendu"

Call CRPublique.save(True, False, True)
'Set itemC = CRPublique.GetFirstItem("BodyR")
'Call itemC.remove
Call CRPublique.removeitem("BodyR")
Call CRPublique.save(True, False, True)
Call view.Refresh
Call workspace.ViewRefresh
Call uidoc.Close
 
I tried the code below and it works perfectly. You will notice that it is a copy of your code, minus a few things I deemed useless for testing purposes.

Code:
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim view As NotesView
Dim docEcran As NotesDocument
'crée un doc vide
Dim db As NotesDatabase
Dim CRPublique As NotesDocument
Dim itemA As NotesItem
Dim itemB As NotesItem
Dim itemC As NotesItem

Set uidoc = workspace.CurrentDocument
Set docEcran = uidoc.document
Set db = session.currentDatabase
Set CRPublique = New NotesDocument(db)
Set CRPublique = docEcran.CopyToDatabase(db)
Call CRPublique.removeitem("Body")
Call CRPublique.save(True, False, True)
Call uidoc.Close

As you can notice, I renamed the body field since my test took place in an existing test db with docs already created from previous tests. I can assure you that the code created a correct copy and removed the body field as required.
Use this code to test. If it works, you can use it as a base and add pieces of your code to it bit by bit. Debug and control, and you'll find what has been breaking your process.

Bonne chance !

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top