How to prevent Lotus Notes from saving a document created by a DXL Import? - lotus-notes

I followed this link enabling me to setup a hotspot in a richtext field - works like charm.
http://ozinisle.blogspot.de/2010/11/lotusscript-code-to-append-hotspot-to.html
Only problem is, as the user(s) usually do(es) not have deletion rights, the document created by the import stays stored in the database. In LotusScript e.g. I can create a new temporary document and work with it, and if I'm not saving it, it just disappears at the end of the function.
Is there a similar way or parameter for DXL import which allows me to just drop the document after I got my rtitem?
Alternatively, can someone point out to me if it is possible to create only the temporary richtext item in/on a document I created as tempdoc via LotusScript?
My search on the web did not get any results and my tries to reduce the linked function always resulted in the error 4518 (which is described in the help document of "DXLImporter"); if I read the help right, the DXLImporter only supports the db as valid output (thus expecting documents being created via DXL).

I don't see a way to import DXL without creating a document.
The easiest solution is to create the temporary document in users "cache.ndk". The user has definitely the right to delete documents there. So, you'd replace the line "Set db = session.CurrentDatabase" in code you linked to with
Set db = session.Getdatabase("", "cache.ndk", false)
The rest of the code would stay the same.
As an alternative, use the more classic approach running an agent on server to delete the temporary document. Create an agent which deletes the document, set property "Run on behalf of" to someone who is allowed to delete documents in database and call the agent from your script with
agent.RunOnServer(noteID)

Related

Get recently read document in Lotus Notes Database

I am developing a database on Lotus Designer 8.5 environment with LotusScript and LotusFormula.
Is there any possibilities on get a list of recently opened documents (for example last five) in a Lotus Notes database ? My purpose is to provide an embedded view showing the recent documents opened by current user on the current database, which will act like some kind of history view.
Please advise
Use a folder categorized by username. Add the current document in PostOpen event to folder with document.PutInFolder(folderName) and remove the oldest document from folder with document.RemoveFromFolder(folderName)
This way you don't need to edit the documents and can show the last visited documents for a user in an embedded view.
As an alternative you can use user specific folders with option "Shared, private on first use".
I have that functionality in one of my databases.
I just added some code in the QueryOpen event of the form to store the UNID of the document in a profile document linked to the specific user. The values are stored in a multi value field, and my code removes the oldest entry when the number of entries I want to store is exceeded.
The user can actually set that number themselves in teh applications settings, 5 is default but they can make it more or less.
I built a class for this, makes it very easy to modify later, and to implement it in different forms, for different document types.
I then built a method to expose the last documents to the user, using a dropdown box as you can see below. Since you only wwant/need the five (or perhas ten) last documents, no need to use a view.

Why cannot I delete a Lotus Notes document?

in my Lotus Notes agent, I temporarily created some documents using a new form (with a richtext field in the form), and in the end of the code, I have "Call TempDoc.Remove(True)", when the program execute this line of code, I got error "Notes error: No documents were deleted", then I commented out this code to let the document saved in the current database, so I manually delete those documents created by my program by click Delete key, but I got the same error "No documents were deleted", I have Manager access with delete option in the database ACL,
Does anybody know why I got that error?
By the way, if I created a new document by using the default form which is not the form used in my program above, then I can delete it.
So, the question may be: what kinds of documents created in the notes database can NOT be deleted by a id with Manager and Delete option?
The NotesDocument.Remove(true) method may be trying to do a "soft deletion", but the database may not be properly set up for soft deletes. If you don't care about soft deletes, then try the NotesDatabase.RemovePermanently(true) method instead.

Invalid UniversalID when document has been copied

I have a strange problem: I want to access documents in a different database (same server). My approach is very close to this one discussed here: http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllFlatWeb/517ef6249d5b9fa6852575cc00503786?OpenDocument
I have only 3 docs in the source database. 2 are created directly, one is copied from another database (these are just test document). We have a generic view that lists thos entries from a view, calcs the links in a form like this:
http://localhost/database.nsf/xpMBK.xsp?action=openDocument&db=dominotest%2Ftest%2Fulcbs%21%21projects%2FFKIE%2FEinsMuB.nsf&view=AMBKEinsAll&documentId=781F14A98A699548C1257C3200316BAC
As you can see we are using an Xpage in the current database and place parameters that point the Xpage to open the document to the source database (notation is server!!database here), a view (this is the one to which I want to return) and finally the unid of the source document.
Now the strange one:
I cannot open the copied document, receiving the
NotesException: Invalid universal id
lotus.domino.local.Database.getDocumentByUNID(Unknown Source)
error.
Even better: if I copy a document that works within the same database (the current one) this document can also not opened anymore!
What's this and can you give me a hint to solve this?
Thanks in advance!
If, by "copied", you mean either manually copied and pasted into the target database or programmatically duplicated via copyToDatabase(), the new copy of the document will be assigned a new UNID; it is not guaranteed to have the same UNID as the original did (and, in my experience, it's rare that it preserves the original). If you're duplicating the document programmatically, be sure to check its new UNID afterward and use that ID in your URL calculation instead.
I've had a problem very similar to this in the past, and the answer turned out to be that I wasn't opening the NSF file that I thought I was opening. I was using NotesDatabase.OpenByReplicaID, and there were two replicas of the database on the server, with different sets of documents. In that situation, Notes gets to pick one of the two replicas -- you have no control over it. The replica that was actually opening contained some of documents corresponding the the UNIDs that I was trying to access, but some of them really were not there and therefore the getDocumentByUNID() method was correct in throwing the "Invalid universal id" error. This was really, really hard to debug.
After I figured it out and removed the second replica from my server, the first thing I did (after testing and confirming the problem went away) was to write an agent that scans a server for duplicate replica IDs.
The UNID:S in a Domino database when it's copied to the database thru copyToDatabase is done like this.
One part of the UNID comes from the database one part is document unique. So if you copy a document from one database to another the document could get the same unid each time. If the unique combination doesn't have a valid document with that combination in the database, the document will get the same UNID everytime. In other cases the document will get a new Id.
More information can be found here
UNID and copytodatabase
Thank you guys for your ideas!
But I was completely wrong #facepalm
The problem was: a colleague coded a bean to access the other database and I didn't noticed that the config document pointed to a replica on another server, so when I copied the document within my database on my local server it was fairly clear that the xpage could not find the copied one - as it resided on the other machine.
Thank you anyway :)

I Need to prevent saved conflict in xpage

Scenario :- I opened the same document in different browsers(users). One user modified and saved the document. another user also modifying the same document which creates saved conflicts. for this I googled and found the link and tried.
http://dontpanic82.blogspot.in/2010/01/xpages-custom-control-that-can-help.html
(Thanks to Mr Tommy).
I included this custom control in another custom control(Form) at the end of Cc.
I am getting currentDocument not found in before render response event. I have my data source name document which is defined for full page not for panel.
Document handle is not getting in Before render response event?
Please help to me to solve this. or is there any other way to prevent saved conflicts?
Have a look at the concurrencyMode property of the document datasource.
You can for instance set it to fail in order for the document save to stop (fail) if a save conflict occurs. If you have (or add) a message control to your xpage, a save conflict error message will then appear.
If you isn't building for XPinc you could use my Document locker project on openntf.org
Document Locker on openntf.org
It works like this, when a user opens a document a< lock is added to an application scope bean. And when the user exits the document this lock is removed. if another user tried to enter the document at the same time they will be redirected to readmode.
Also, check the section in Mastering XPages 2nd Edition about document locking. That gives thorough examples for enabling the in-built Domino document locking.

Lotus script agent does not make any update when ran from an Embedded View in lotus notes

I have an embedded View within my form which has a bunch of agents in the embedded view.
However when i select rows(documents) in the embedded view and run the agent (eg "Do a multi profile update") it does work but it does not make any changes to the documents selected. Like the prompt in the lotus script agents does work and pop up but no updates are made.
When ran externally from the view it works fine so for some reason it does not work from an embedded view is what i feel.
The agent within the view is an Action which uses a formula language code #Command([RunAgent];"updatePeople")
were the updatePeople is a lotus script agent.
any ideas or suggestions guys?
I think you have to access the selected documents using an action in the embedded view with the LotusScript logic inside the acrtion instead of calling agents. You can find a complete answer here (with full explanation and code sample):
Domino Designer: Access selected rows from embedded view
I am not sure if this IBM TechNote explains exactly the same issue, but it seems very similar:
How to get a handle on selected documents in an embedded view when using LotusScript
Does the ID have the correct ACL settings for the agent to run?
Does the ID have the ability to edit documents?
Does the Agent have the proper save statements in the code?
The example code in the above link is doing a full db search of unprocessed documents. I would suggest using the ViewEntry document collection. This will allow the agent to run faster since the view could be customized.
Another way to go if you are having issues with processing is to set up a flag field that is updated with the save of your document. The flag field could be used in your view selection field to have the documents fall out of the view if that is desired.

Resources