Solved

Immediately trigger backend agent

Posted on 2004-04-14
15
415 Views
Last Modified: 2013-12-18
What is the best way to trigger a backend server agent (immediately) to create B (child) document when A (parent) is saved ?
In another words:

I want when document A is saved AND
If FieldOne = "TypeA" then
   Create a child document (triggered immediately after the save or doc A by a backend agent)
Else
  Just save doc A

This app is on LN 5.0.10 and LN 5.0.10  client
Note: I have already used the functionality of ' if document has been modified and saved ' for the agent but i cannot have the system wait if there is a delay due to agents queue. I want it immediately triggered just like servlet works on web.

0
Comment
Question by:navgup
  • 5
  • 5
  • 3
  • +1
15 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 10829832
Don't put it in an agent then.  Put it in the UI events for the form!
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 75 total points
ID: 10830044
And explain why it has to run on server.

Did you try: NotesAgent.RunOnServer(NotesDocument.DocId)

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10831130
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:navgup
ID: 10836042
Qwaletee, I don;t understand what UI event of form are you talking about ? Pl explain.

Zvonko:
I am concerned about the security for running this agent (AG1):
For eg.
A parent document A is created by User X, who do not have access to run 'Restricted/Unrestricted' agents on the server,
Agent AG1 is signed by the administrator of the notes server.
Will UserX be able to trigger the agent (using RunOnserver) on the server?

Thanks

0
 

Author Comment

by:navgup
ID: 10836412
Also, there is one more concern i have. Even if the backend agent creates the document, what is the best way to have
newly created document inherit the required fields from the parent document. How is it possible to do it more effectively in the backend on the server (just like ComposeDocument works)?

I know one way is to copy items one by one from one doc to another... which is going to be very tedious.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10836622
Did you try to make that AG1 run as scheduled agent on new and modified documents? That would be the normal aproach.
Whithin that run does the AG1 decide wether to create a response document or not and set a flag in parent document that those document is handled (in case you modify it later and do not want to have two response documents for a single parent)
The documents for NewOrModofied documents are presented as DocumentCollection.
There is always a delay when running the scheduled agents, you cannot force it to run immediately.

The security for RunOnServer is taken from Notes client usser, the caller, not the Agent signer. So if your user.id does not have the priviledge to run unrestricted commands, then will the agent abort when trying to do so.

0
 

Author Comment

by:navgup
ID: 10836725
Well.. i don't quite understand your second paragraph. These users have access to create child document (Authors) in the database as they are normal users to the server (not a power user or admins). These users are listed in the "Run restricted LotusScript/Java agents:" on the server but they are not in "Run Unrestricted LotusScript/Java agents". Does this kind of agent (just to create a document) falls under restrcited or unrestricted category ? I thought it falls under restricted category.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10836776
If the users are allowed to create documents, then the agent will also be allowed to do so.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10836789
But that is important only if you want to run the AG1 from Notes Client on the Domino server.
The regular way is to let the AgentManager run the scheduled agent AG1.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10841296
Qualetee meant not to use agents at all.

Put this in the QuerySave or (better) the PostSave event:

Sub PostSave(uidoc As NotesUIDocument)
    dim doc as notesdocument
    dim db as notesdatabase
    dim childdoc as notesdocument

    set doc= uidoc.document
    set db= doc.parentdatabase
    set childdoc= new notesdocument(db)
    replaceitemvalue "Form", "form of a child document"
    replaceitemvalue ..., ... ' add other fields here
    childdoc.makeresponse(doc)
    childdoc.save(true,false)
End Sub
0
 

Author Comment

by:navgup
ID: 10844660
Like i said earlier, there are too many fields to inherit and i cannot assign values to each field from the parent
document.
Is there a better way to perform inheritance (synchronize) in the backend (not necessarily from parent to child but between just
two main documents)?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10845218
You "cannot assign values to each field from the parent document". Not true. Should be read as
You "don't feel like writing all the code to assign values to each field from the parent document". It's a normal thing. :)


How about the NotesDocument.CopyAllItems method? Or you can make a complete copy of the document and then modify it?
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 10863248
Or, if you name the "shared" fields using a conventio that can differentiate them from the other fields, you can loop and pick off teh "matching" fields with about 6 lines of code.
0
 

Author Comment

by:navgup
ID: 10863549
qwaletee: can you provide me with those 6 lines of code.. ?
I don;t understand how having shared fields is going to help me sync up the data between one form to another?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10866830
Use names that are alike, such as starting with a prefix that indicates sharing, e.g. in both forms name the "shared" fields like "ShrFieldname", so you can copy all fields starting with "Shr" to the other document.

Basically:

Dim items as variant

Set items= doc.Items
Forall itemi in items
    If Left(itemi.name,3)= "Shr" Then
        itemi.copyitemtodocument(otherdoc)
    End If
End Forall

Or equivalent.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now