Isn't the UniqueId really unique?

The following line in a script

Set docTask = dbTask.GetDocumentByUNID(note.TaskUniqueID(0))

fails with an error message of “Invalid universal Id”

According to the debugger

  • dbTask is pointing to the correct database

  • the value of note.TaskUniqueID(0) is at the call above = 3EA3D86C3EA32714C1256CD00046001E, (It was previously established in another script by note.TaskUniqueID = docTask.UniversalID )

The properties of the document in dbTask that docTask should end up pointing to after the script line above shows

There is no ACL-issue.

Can anybody please help me identify what’s wrong?

Subject: Make sure it’s a string…

As far as I can see all looks well in the construction of this UNID & it seems to match the target doc’s unid.

So, just to make sure that it is definitely a string that you’re passing to the getDocumentByUnid method stick some type conversion in there…

set docTask = dbTask.getDocumentByUnid(“” & note.TaskUniqueId(0))

Subject: When

When callingSet docTask = dbTask.GetDocumentByUNID(note.TaskUniqueID(0))

is docTask saved document in the database ?

If yes, then have no idea - should work.

Subject: No

No,docTask has just been declared Dim docTask As NotesDocument

prior to the

Set docTask = dbTask.GetDocumentByUNID(note.TaskUniqueID(0))

(note is a saved document)

Else ?

Subject: Re

TryPrint “note.TaskUniqueID(0)=”+note.TaskUniqueID(0)

before calling getDocumentByUNID.

Subject: RE: Re

???

Subject: GetDocumentByUNID hassles

Is the task document that you’re trying to look up, also a saved document? The final UNID is not assigned until the document is saved.

It doesn’t matter whether note has been saved.

Subject: RE: GetDocumentByUNID hassles

Yes,both the task document (that i try to point docTask towards) and the note document (that I want to read the UNID reference to task from), are already saved and closed documents.

Subject: Web ?

When QueryOpenAgent works, then UNID is different from the one, that really is assigned when document is saved.

Subject: RE: Web ?

Luckily, I don’t have to work with web clients :slight_smile:

Subject: Isn’t the UniqueId really unique?

This method is reliable and the UNID is really unique (not that uniqueness is the issue here). Is it possible that your code is looking for the document in a replica of the database that hasn’t yet received the document?

Subject: RE: Isn’t the UniqueId really unique?

The databases resides on the server, so it should basically not be this issue causing.the problem.

However, you may possibly have a point here, as there are some local replicas of some of the databases involved, and there are some OpenByReplicaId statemenst involved in the code in some other functions that are called somewhere else. However, the Open Replica of all the relevant bookmarks currently refer to the database replicas, so I would not think this is the problem, but I shall look into this more deeply.

Thanks for the input!

And for the UniqueID being unique, well…

It took me quite some time some years ago to discover that a field that had been set by the unique @ReplicaId gave incorrect result when using the field value in a db.OpenByReplicaID – because Lotus Script doesn’t understand the colon in the middle of the ID that is allways presented elsewhere in the system, including from @ReplicaID.