Greenman Posted June 28, 2011 Posted June 28, 2011 I have a script set to run daily at midnight. It emails me only if there are tasks due in exactly 14 days. I have the script set to find unfinished tasks with today's date + 14. It works fine if there is something to be found. Perform Find [Restore] If [Get(FoundCount) ≠ 0] Go to Record/Request/Page[First] Loop ... do stuff ... Go to Record/Request/Page[Next; Exit after Last] End LoopElse Show all Records End if When I run it as a normal user and the found set is empty, it asks me if I want to 'modify or continue'. I don't see a way to automate 'continue' when the script is running automated from the server. Am I missing something?
bcooney Posted June 28, 2011 Posted June 28, 2011 Yes. Set Error Capture On. You don't need the Else Show All Records, either. Make sure your script starts in the proper layout. There should be a Go To Layout before the Find.
Greenman Posted June 29, 2011 Author Posted June 29, 2011 Yes. Set Error Capture On. You don't need the Else Show All Records, either. Make sure your script starts in the proper layout. There should be a Go To Layout before the Find. Thanks! You got me going in the right direction. Definitely helps to specify the layout first. And thanks for confirming that 'else show all records' was unnecessary. I suspected it wasn't. The finished script: Go to Layout ["Task List" (Tasks)] Set Error Capture [On] Perform Find [Restore] If [Get(LastError) = 0] Go to Record/Request/Page[First] Loop ... do stuff ... Go to Record/Request/Page[Next; Exit after Last] End LoopEnd if Set Error Capture [Off]
bcooney Posted June 29, 2011 Posted June 29, 2011 That looks good. You don't need to Set Error Capture Off. Server scripts behave as if the user logs in, performs the script and logs out. So, nothing persists after the script runs. Also, any script that you run on File Open will run with each server script. That could be a good thing as forgetting to set necessary globals is often forgotten. Just a point on style, I never use Perform Find (Restore). I can't read the script after and see what my Find criteria are. Rather, I structure all Finds this way: Set Error Capture On Go to Layout "MyFindLayout" Enter Find Mode Set Field (field; criteria) Perform Find If (Get (FoundCount >0)) do stuff Else do this End If
Greenman Posted June 29, 2011 Author Posted June 29, 2011 That looks good. You don't need to Set Error Capture Off. Server scripts behave as if the user logs in, performs the script and logs out. So, nothing persists after the script runs. Also, any script that you run on File Open will run with each server script. That could be a good thing as forgetting to set necessary globals is often forgotten. Just a point on style, I never use Perform Find (Restore). I can't read the script after and see what my Find criteria are. ... Thanks for the hint about Set Error Capture Off. I have often used the find-mode/set-field method, but have recently found that sometimes I like being able to specify using restore. It can be quite precise. These two dialog boxes make it pretty easy: In the first dialog box above, I get to add as many consecutive finds as I like, including, as you can see, an omit. The second dialog box allows me to specify exactly what this part of the find should do, including variables I've set earlier in my script! That can be awfully convenient.
bcooney Posted June 29, 2011 Posted June 29, 2011 Yes, true. But when you read the script, unless you "open" the Perform Find (restore) script step, you cannot see the criteria. It's really a matter of style.
Greenman Posted June 29, 2011 Author Posted June 29, 2011 Yes, true. But when you read the script, unless you "open" the Perform Find (restore) script step, you cannot see the criteria. It's really a matter of style. Ah - so you like being able to see directly from within your script step dialog exactly what's being found. You're right -- it is a style preference thing. Thanks for clarifying.
Greenman Posted June 30, 2011 Author Posted June 30, 2011 Okay here's something weird... When I run this script as the user 'cron' - a limited user - from my computer it works. When I run this script as user cron from the server set to run at 12:08 AM, it doesn't. Script Debugger shows Error 101, (Record is missing) but the one found record is plainly visible when it runs and an email is sent. I can only guess that it stops for some misunderstood reason when run by the server. I'm confused because it works for me as the limited user, but not when the server automatically calls the limited user to do the same. < mumbling many swear-words under breath... >
IdealData Posted June 30, 2011 Posted June 30, 2011 Okay here's something weird... When I run this script as the user 'cron' - a limited user - from my computer it works. When I run this script as user cron from the server set to run at 12:08 AM, it doesn't. Script Debugger shows Error 101, (Record is missing) but the one found record is plainly visible when it runs and an email is sent. I can only guess that it stops for some misunderstood reason when run by the server. I'm confused because it works for me as the limited user, but not when the server automatically calls the limited user to do the same. < mumbling many swear-words under breath... > Script debugger always reports a 101 after running off the end of a found set in a loop.
Recommended Posts
This topic is 4896 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now