Solved

Immediately trigger backend agent

Posted on 2004-04-14
15
412 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

16 Experts available now in Live!

Get 1:1 Help Now