Link to home
Start Free TrialLog in
Avatar of khanhna
khanhna

asked on

delete documents

Hi Expert,
My form has an action which I want to delete all documents from 2 views and perform some other tasks. For delete documents, I have created 2 agents. When I assign this 2 agent to the action of the form, it always said that I have to run these agents from a view. Is there any way to delete document without using agent?
Thanks,
Avatar of CRAK
CRAK
Flag of Netherlands image

You could write code in lotusscript right in the button's Click-event.
Start off at a New NotesSession, use CurrentDatabase to gain a NotesDatabase object. From there use GetView to access a NotesView. From there the approach may depend on what's in it. Either delete doc's one by one or collect a number by key (viewentries or documents) and delete the bunch.

But there's an easier way:
Make the agent run on "all doc's in database".
Press the "Add search" button, select "Folder" and select the view that you want to delete from.
You could use "Simple action" to emtry the view: "Delete from database".

That's all!
can u please paste your code?
It depends on the requirements also. U said it performs other tasks. We want to know what are those other tasks.

if your code is perfect, then in the Agents select RunOnce @Commands....
and run on all documents in view.

This should work.

Avatar of khanhna
khanhna

ASKER

Hi CRAK, I write Notes script, and use GetAllDocumentsByKey... and delete one by one... but how can I delete a set of records instead of delete on by one?
no other option.

U have delete one document and refresh the view and get another document and delete.

it is some what tedious method.
Workaround will be to create a view and give the selection formula in the view.

So, it will displayall those documents which are ready to delete. then Select all and delete or u can try with code to delete.
ASKER CERTIFIED SOLUTION
Avatar of CRAK
CRAK
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial