7 Replies Latest reply on Apr 9, 2007 5:42 AM by craig_mac

    schedule task

    craig_mac Level 1
      hi i have a page of code which includes a form, this page works fine when entered into the address bar, but not as a scheduled task,

      can schedule task process forms?
        • 1. Re: schedule task
          Sojovi Level 1
          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.

          • 2. schedule task
            craig_mac Level 1
            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?
            • 3. Re: schedule task
              SafariTECH Level 1
              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.

              • 4. schedule task
                craig_mac Level 1
                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
                4.delete email
                5. go back and loop through the next csv
                • 5. schedule task
                  SafariTECH Level 1
                  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.
                  • 6. schedule task
                    craig_mac Level 1
                    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
                    • 7. Re: schedule task
                      craig_mac Level 1
                      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?