Creating an Anonymous document using script

Using the Notes Client Only (not web), Is it possible to create an anonymous document ($Anonymous=“1” and no $Updatedby field) when creating a document in script?

If so, How?

I’ve tried several options, ie.

-Adding a $Anonymous field before saving the doc,

-Creating a form with the option Anonymous Form and doing a ComputeWithForm before saving the doc,

-and some variations of the above.

Subject: Creating an Anonymous document using script

can you post the entire code you’re using to create the doc. the second option you posted should work in theory. Are you saying the doc is saved but it’s not anonymous ($UpdatedBy field is present)?

Subject: RE: Creating an Anonymous document using script

The form has Option Anonymous Form checked. Here’s the code I’m using:

Dim se As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Dim doc As NotesDocument

Set doc = se.CurrentDatabase.CreateDocument

doc.Form = “ContactTitle”

doc.ContactID = uidoc.FieldGetText(“ContactID”)

Call doc.MakeResponse(uidoc.Document)

doc.Org = uidoc.FieldGetText(“CompanyName”)

doc.Title = uidoc.FieldGetText(“JobTitle”)

doc.OfficePhone = “”

doc.EmailAddress = “”

doc.ComputeWithForm True,False

Call doc.Save(True,False,True)

Call uidoc.Refresh

The document is created just fine, but it’s not Anonymous.

Subject: RE: Creating an Anonymous document using script

I think you may be out of luck. The $UpdatedBy field gets created when you call the Save method. I thought maybe you could pull the new doc into the UI and have the user save it on exit but the MakeResponse method requires you to call the Save method in order for it to work so you can’t do that. I’ll keep poking arouns but I don’t think you can create an anonymous document via the backend.

Subject: RE: Creating an Anonymous document using script

Geez :frowning:

You would think that of all the documents that you would want to be Anonymous, one created in the background would be one.

Subject: RE: Creating an Anonymous document using script

I have tested a workaround (and it worked) that is on the IBM Website at this address :http://www-1.ibm.com/support/docview.wss?uid=swg21102782

Sub Initialize

Dim s As New notessession

’ scrcdb is the source database.

Dim db As notesdatabase

Dim coll As notesdocumentcollection

’ doc is source document and doc2 is new document without $Updated field

Dim doc As notesdocument

Dim doc2 As notesdocument

'AnonymItem will be used to add $Anonymous field to doc2

Dim AnonymItem As Notesitem

Set db=s.currentdatabase

Set coll=db.unprocesseddocuments

For i = 1 To coll.count

Set doc=coll.getnthdocument(i)

Call doc.removeitem(“$UpdatedBy”)

Set doc2=New NotesDocument(db)

Call doc.copyallitems(doc2)

’ $UpdatedBy field will be deleted only if $Anonymous field exists

If Not (doc.HasItem( “$Anonymous” )) Then

Set AnonymItem = New NotesItem( doc2, “$Anonymous”, “1”)

End If

Call doc2.save(True,True)

Call doc.remove(True)

Next

End Sub

Be careful, if later you delete the field $Anonymous from the document and save it, the $UpdateBy, $Revisions, are automatically recreated.