This content has been marked as final. Show 7 replies
Schedule tasks process pages, not part of it (i.e. : a form inside a page). You can add the URL parameters you need and control de code flow to execute the part of the page you need.
ok thanks, but still not sure how i can process a form, ie i need to insert csv files into my table, how would i change my code to do this with a scheduled task?
create an action page that uses URL variables and then the page will run via scheduler.
as noted, a form cannot really be processed unless there is interaction with a user ... but CF pages passed URL variables can process on their own.
ok thanks i undrstand now, but will the url variables be able to hold currentrow information
ie the form i have now gets its values from a csv file, looping through each record, can that work with url?
also the schedule page loops through multipul csv files, so if i have a action page how can the schedule page loop through the next csv?
what i need to do is
1. loop through email csv attachments
2. read the csv
3. insert the csv information into my database
5. go back and loop through the next csv
This is part of that CFPOP thing you are working on I guess ...
If the data is not time sensitive, I would probably suggest doing something a bit different and running the task at set intervals ... maybe once or twice a day or something.
Based on what I have skimmed through regarding that project, I think you should have the CFPOP service save the attachments to a set directory reserved for the CSV files (I think you are doing that already). Make sure they have a CSV extension.
Separate from above, in the task page, use CFDIRECTORY to get a list of all the CSV files, filtered by *.CSV, so it ignores any other possible attachments that show up.
Loop through this list and read each file using CFFILE then add the data from that CSV to the database.
Once completed, move to the next file.
When all the CSV files in that current list are read and entered, use the list again to delete the files already used so they do not get entered again.
This is a very grassroots approach to what you want to do, but would run w/o any need for forms and could process within a silent task page via scheduler.
ok thats sounds good, but i need to run this every 60 seconds, as when i receive the email whith the attachment i need to upload it as quick as possible.
if this would work every 60 secs, can you post some example code to get me started.
just another question is there another way of inserting a csv into a database other than using a form?
thanks for your help
i just found the code attached, to read the csv file, but i am getting a error of
any ideas what i need to change, and will this work on a scheduled task?