I have posted this question before and I did receive some feedback - however, as I was out of the office on business, I was unable to reply until now.
I have an agent that displays a form ( tag in the agent). I am trying to save the data entered into the form every 10 minutes or so (for testing purposes, I used 30 seconds).
Stan Rogers replied with regards to using the setTimeout(30000,“documents.form[0].submit()”) and calling it from the onload of the form.
What I did was add the following:
Print ||
to my agent. However, I get an out of memory error - like the form just keeeps trying to reload over and over again.
I would post more code, but my agent is quite large.
Any ideas on what I may have done wrong would be greatly appreciated, or any other ideas on how this might work. The biggest thing is that I do not have a notes form used.
By the way, should I have responded to the original post? I thought that after a week or so, it may be checked.
Thanks in advance.
Subject: Automatic Save in Web Agent
Responding to the original would have got me, since I use the “flat” view, where the most recent post is at the top, but a new thread mightn’t hurt getting additional ideas.
Can you post the actual, entire Print statement?
Subject: RE: Automatic Save in Web Agent
Here’s a snipit of code in my agent:.
.
.
Print “function setTimeout()”
Print “{”
Print |var f=document.forms[0];|
Print |setTimeout(30000,“f.submit()”);|
Print “}”
.
.
.
Print ||
Print ||
.
.
.
That’s it!
If I add an alert to the setTimeout function, it is like I am caught in an infinite loop.
I have an <input type = button …> in the agent that when it is pressed, it saves as a draft. Is there a way I can simulate pressing that button after a certain amount of time?
Thanks for the help!
Subject: RE: Automatic Save in Web Agent
Ah. You have a function declared that has the same name as a native method, which is going to cause a whole bunch o’ confusion. Rename the function, and things should work differently.
Subject: RE: Automatic Save in Web Agent
Will do - I’ll let you know how it works.
Thanks!
Subject: RE: Automatic Save in Web Agent
OK…
I removed the setTimeout function altogether. And I changes my body tag as follows:
Print |<BODY onLoad=“setTimeout(5000,“document.forms[0].submit()”)”>|
Do I need to add something before the setTimeout to let the system know it is javascript?
Print |<BODY onLoad=“javascript:setTimeout(“document.forms[0].submit()”,5000)”>|
Subject: RE: Automatic Save in Web Agent
No, the onload event binds to JavaScript (ECMAScript) by default – but you’re going to want to replace the inner double quotes with single quotes:
onLoad=“setTimeout(5000,‘document.forms[0].submit()’)”
Subject: RE: Automatic Save in Web Agent
Stan - you are the MAN!!!
Thanks so much for all of your help. Here is the finished product!!!
Print ||
Another question for you - when the document submits, I run another agent that saves the document. If I don’t add any additional code, I get an Agent Done message. If I add javascript in my save agent to return to the previous page, the review form appears, but the user is placed at the top of a comment box. Is there anyway to have the data save, while keeping the user where they are?
Thanks again!