Link to home
Start Free TrialLog in
Avatar of kalios
kalios

asked on

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
Avatar of HemanthaKumar
HemanthaKumar

Most agent activity is on server (i.e. background).. So I am not sure why or where you are seeing the delay.

~Hemanth
Avatar of Sjef Bosman
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
SOLUTION
Avatar of Bozzie4
Bozzie4
Flag of Belgium 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
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
Avatar of kalios

ASKER

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.

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.
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 ?



Avatar of kalios

ASKER

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
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....
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)
Sorry Tom, the default for AMgr_DocUpdateAgentMinInterval is 30 minutes. At least that's what the Admin Help says.
Avatar of kalios

ASKER

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
That's possible too :-)

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

cheers,

Tom
SOLUTION
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
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.
Avatar of kalios

ASKER

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
Avatar of kalios

ASKER

"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




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.
Avatar of kalios

ASKER

yes, thanks again.
Can you please give me a sample code on how to read documents from a particular view and process them.
ASKER CERTIFIED SOLUTION
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