Webquery Save Agent Alternative

Hi,

I've two forms. One is for web and one is for Notes. Both have the same field names and same fields.  When the web form is saved it is also saved in Notes. Now the question is I'm running a webquery save agent.
This webquery save agent does lot of processing as it reads some fields from the webforms and updates other documents in the database. I've a particular field in the webform which can really have large number of values (Multiple Values). When there are large number of values in this field it is taking lot of time after clicking the submit button to process as the webquery agent should read all those fields. In this case the user will have to wait for a long time to see the next screen which gives the confirmation. The reason is the webquery agent is running in the background.  

Is there any way I can run this webquery agent later after fully submitting the form. Or can I run this agent in the Notes form (like in query save or some where else)...


Please advise and let me know if I'm not clear.
thanks
Kalios
LVL 2
kaliosAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
Sample code? Well, here you go, untested as usual:

Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim nextdoc as NotesDocument
Dim view As NotesView

Set db= ns.Database
Set view= db.GetView("yournewview")
Set doc= view.GetFirstDocument
Do Until doc Is Nothing
    Set nextdoc= view.GetNextDocument(doc)
.....processing
    Call doc.RemoveItem("PostProcessing")
    Call doc.Save(True,False)
    Set doc= nextdoc
Loop
0
 
HemanthaKumarCommented:
Most agent activity is on server (i.e. background).. So I am not sure why or where you are seeing the delay.

~Hemanth
0
 
Sjef BosmanGroupware ConsultantCommented:
You'll certainly notice the delay, for the agent runs "real-time". There are two options:
1. you add a field to the document, stating that it needs post-processing; you create an agent that processes the yet unprocessed documents
2. you trigger a second agent from the WQS agent; keep in mind that the document is NOT saved yet, so the second agent shouldn't run within a second

I prefer the first method, but only if the updates to be done can be postponed 15 minutes or so, because nobody needs them
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Bozzie4Connect With a Mentor Commented:
Actually, you can see a delay, if you haven't enabled "Run web agents concurrently?" in the server document.

So enable this setting and check if performance is better.  There is btw hardly any difference in running the wqs agent, and processing formulas (agent will be a lot slower, but this should not be hardly noticeable in web apps).  Formula's run in the background (on server) too, although they can by default "run concurrently"


cheers,

Tom
0
 
Bozzie4Commented:
And if the form has a lot of fields, maybe your delay is caused by the huge amount of data you upload to the server  ?

There are some solutions to this as well:
Use 2 WebQuerySave agents.  In the first, use print statements to return a message like "Please wait".  Put actual processing in the second.  Don't call the 2nd from the first, though, like Sjef says, because you won't gain anything.  Just do
@command([toolsrunmacro];"WQS1");
@command([toolsrunmacro];"WQS2")

cheers,

Tom
0
 
kaliosAuthor Commented:
I've a $$return field in the form. So when I submit the form it will redirect me to the link specified.
However, there is a lot of delay after I click the submit button. It tries to run the webquerysave agent.
The page just sits like that for a while (sometimes even 15 minutes depending upon the fields in the big multi-value field).  

It looks like the $$return is waiting for the webquerysaveagent to finish processing.

0
 
Sjef BosmanGroupware ConsultantCommented:
15 minutes?! That's not very user-friendly...

I assume you tested with and without the WQS-agent, and that running without completes within a few seconds. I have several applications with PostProcessing-agents, all without a glitch. The agent is triggered automatically on "When documents are added or modified", and it is sometimes necessary to set the trigger to appear more frequently (e.g. every 15 minutes. The second advantage of this approach is that you can handle the PostProcessing of multiple updated documents.

Eh, if  may ask: what the h*ll takes 15 minutes to process?? It might be worthwhile to put another question inhere to speed up your algorithm.
0
 
Bozzie4Commented:
I have to sadly admit that my 2 wqs agents approach does not work.  It processes them both, but only returns a result from the second ....  Same result as  calling 2nd from first agent (sorry sjef:-) ).

WQS takes precedence over $$Return - so, yes you will have to wait till your agents finishes.

Another option is to launch a second window (using javascript) when submitting, or to simply open a new page when submitting, or to direct your submitted form somewhere else.  That way you can still ask the user for some patience :-)


Have you already checked the "run agents concurrently" setting ?



0
 
kaliosAuthor Commented:
I did not check run agents concurrently. I'll try to do that... I'm going to put another question and will put my code in there and lets see it can be improved. Just like the webquery save agent can I have something in notes form that will run an agent as soon as a document i saved.



thanks
Kalios
0
 
Bozzie4Commented:
Yes, that's what Sjef is trying to tell you.  You will have a delay of (standard) 5 to 10 minutes, but there are notes.ini settings you can set to adjust this delay down to 1 minute....
0
 
Sjef BosmanGroupware ConsultantCommented:
The first I knew (2 wqs agents will run sequentially and real-time), the second I did know (calling the second agent) but I always think again that "triggering" is an a-synchronous operation and therefore it isn't the same as "calling". Wrong again.

I'd say, since all other options are more or less makeshift and will lead to poor quality solutions, go for the PostProcessing. Think very carefully what has to be done NOW (validations, computations that are shown on the screen, etc), and what can be done LATER (mails, updates of other documents, etc)
0
 
Sjef BosmanGroupware ConsultantCommented:
Sorry Tom, the default for AMgr_DocUpdateAgentMinInterval is 30 minutes. At least that's what the Admin Help says.
0
 
kaliosAuthor Commented:
Hi,
I've put another question with the code. Also can you please be a little more clear about post processing.
Where do i call the agent in post processing

thanks
kalios
0
 
Bozzie4Commented:
That's possible too :-)

I probalby got them mixed up (there is 1 parameter that defaults to 5, I am sure !)

cheers,

Tom
0
 
qwaleteeConnect With a Mentor Commented:
PostProcesisng that everyone is refering to means don't use a WebQuerySave agent.  Instead, put ALMOST the same code into an agent set to run "when documents are added to updated in the database."  Notes will wkae this agent up periodically when there are new documents or updated documents.  It can then use db.unprocessedDocuments to get the list of documents that need to be processed, and session.updateProcessedDoc to remove the doc form teh processing queue.

The user never "sees" the agent running (good), but the agent does not run immediately (bad).
0
 
Sjef BosmanGroupware ConsultantCommented:
You don't call the agent! It will be called automatically, if you set the agent to be triggered "When documents are added or modified". As soon as the server thinks it has time, the agent is started. I normally create a simple view that matches only the documents that need postprocessing. The agent should walk though these documents and do whatever is necessary.
0
 
kaliosAuthor Commented:
Sjef,

Thanx for the explanation. I guess though there will be a little delay in the updates, I guess this would solve my problem. I would like to go with the post processing approach.  

I can select the post processing agent with target as "when documents are added or updated in the database".

But I only want to run this agent for new documents that are created for form "PortalAD". How is it possible.
How do I specify it in the code ?

If you see I've put another question subject: Improve Code for better performance
I want to run that code here..

thanks much
Kalios
0
 
kaliosAuthor Commented:
"I normally create a simple view that matches only the documents that need postprocessing. The agent should walk though these documents and do whatever is necessary".  
I can create a view which matches my criteria and that should effect the agent.
How does the agent walk through these documents only?

thanks
Kalios




0
 
Sjef BosmanGroupware ConsultantCommented:
As I suggested, add one field to the document when saved, called PostProcessing, and set it to "1". The view can just contain the select-statement
    SELECT PostProcess<>""
Your agent will then open that view, handle each document that's in there and finally it will remove the item PostProcess. Only new documents will be handled, since existing documents will never appear in the View.
0
 
kaliosAuthor Commented:
yes, thanks again.
Can you please give me a sample code on how to read documents from a particular view and process them.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.