• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

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!
0
shuboarder
Asked:
shuboarder
  • 7
  • 6
  • 2
1 Solution
 
Steve KnightIT ConsultancyCommented:
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
0
 
Sjef BosmanGroupware ConsultantCommented:
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?
0
 
Steve KnightIT ConsultancyCommented:
Hmm those Q details have changed completely .....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
shuboarderAuthor Commented:
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.
0
 
Sjef BosmanGroupware ConsultantCommented:
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
0
 
shuboarderAuthor Commented:
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?
0
 
Sjef BosmanGroupware ConsultantCommented:
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
0
 
shuboarderAuthor Commented:
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.
0
 
Sjef BosmanGroupware ConsultantCommented:
The current code doesn't pay attention to the document selection indication in the agent. If you want that, the code should be a little bit different. I suppose you don't have a separate view called SomeViewThatShowsOnlyActiveUsers? That was the prerequisite for the agent...

The code that uses the document selection:

    Dim ns As New NotesSession
    Dim db As NotesDatabase
    Dim dc As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim newdoc As NotesDocument

    Set db= ns.CurrentDatabase
    Set dc= db.UnprocessedDocuments
    Set doc= dc.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= dc.GetNextDocument(doc)
    Loop

0
 
shuboarderAuthor Commented:
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?
0
 
shuboarderAuthor Commented:
Strange.... they've just appeared! about 15 minutes after the agent ran?
0
 
Sjef BosmanGroupware ConsultantCommented:
Weird... F9 to refresh the view?
0
 
shuboarderAuthor Commented:
Yeah, I tried the F9 immediately. Also shut notes down and restarted - they just appeared like 15 minutes later
0
 
Sjef BosmanGroupware ConsultantCommented:
When it's a scheduled agent, it doesn't necessarily run immediately. Domino decides when to run it.
0
 
shuboarderAuthor Commented:
ok, seems to be working ok...

Thanks for your help as always!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now