Link to home
Start Free TrialLog in
Avatar of shuboarder
shuboarderFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Create Documents In A View Agent Based On Another View's Documents And Status

Hi all,

it's been a while....

I need an agent that will create documents in a view on a daily basis.

I want this agent to look at another view (lets call it view1) and collect all names with a status of "Active"
Then, create (in view2) new documents with today's date for each of these names.

i.e. view 1:

Name             Status

Smith             Active
Jones             Not
Campbell        Active

On daily basis agent looks at view 1 and should create in view 2:

Date             Name            Details

18/05/06      Smith
18/05/06      Campbell

Thanks for your help!
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

OK it looks like all you need to do from that is take the view selection formula for view 1 and adjust slightly for view 2 by adding a status check, i.e.

select form="myform" & someothercondition="something" & statusfield="Active"

and maybe sort / categorise view 2 differently and add your details field as another column.

Can you elaborate a bit more?

Steve
Why do you need documents to be created? Since the view could contain the same documents as in the other view, but only the Active ones?
Hmm those Q details have changed completely .....
Avatar of shuboarder

ASKER

I need to record details on a daily basis for each active employee.
Which employees are active can change on a daily basis.

I don't see how this can be done in any other way than I set out in my original question.
Two alternatives:
- log the status changes in a log record document, with date and time, e.g.
    Dirt. E. Harry, 1-1-2006, Active
    Dirt. E. Harry, 1-1-2006, Inactive
 with some relational lookup you can find out what he did on a certain date
- log those changes in the user's document itself, in one or more multi-value fields
Either I'm not understanding, or you're not quite with me....?

View 2:

Date (Categorised)            Name             Today's Details

The view has to have the above structure. i.e. need to see individual document per day per active employee
The Today's details column is edited directly in the view

However at present this view lists all employees and requires each employee document to be created every day.
I would like employee documents to be created automatically only for the employees that at the time the agent runs are active.

Don't know if that helps?
Ah understand.

A scheduled agent, running early in the morning, with target None:

    Dim ns As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim newdoc As NotesDocument

    Set db= ns.CurrentDatabase
    Set view= db.GetView("SomeViewThatShowsOnlyActiveUsers")
    Set doc= view.GetFirstDocument
    Do Until doc Is Nothing
        Set newdoc= New NotesDocument(db)
        Call newdoc.ReplaceItemValue("Form", "TheFormnameYouWant")
        Call newdoc.ReplaceItemValue("Date", Today)
        Call newdoc.ReplaceItemValue("Name", doc.Name)
        Call newdoc.ReplaceItemValue("Details", "")                            
        Call newdoc.Save(True, False)
        Set doc= view.GetNextDocument(doc)
    Loop
Ok,

it's nearly there.

It creates the documents in the correct view, but creates thousands.
How/where do I specify to only create documents for "active" employees?

I tried this in the document selection for the agent but this seemed to make things worse.
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France 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
Still no luck....

Now it is not creating anything.

If it helps it needs to look at view1 >> pick all "active" employees
create records for these in view2.

I have a view that displays all users. no one which displays only active users.

Would it be easier to create a hidden view only displaying active users?
Or is it not too difficult to write this into the agent?
Strange.... they've just appeared! about 15 minutes after the agent ran?
Weird... F9 to refresh the view?
Yeah, I tried the F9 immediately. Also shut notes down and restarted - they just appeared like 15 minutes later
When it's a scheduled agent, it doesn't necessarily run immediately. Domino decides when to run it.
ok, seems to be working ok...

Thanks for your help as always!