I have a web application that I am building. I want to use the Import Excel Genie to import data from the user and then update the data in the temporary dbf table it creates. The one challenge is I need to get field value that is on the grid and update a column in the temp dbf. How can I set this as a session variable? Also, I want to perform updates on two other columns that would be derived from a select statement against my backend MQSQL database.
I looked for documentation on this Genie/Feature pack but was not able to find anything.
I copied the function prototype, but not sure I am heading in the right direction.
I looked for documentation on this Genie/Feature pack but was not able to find anything.
I copied the function prototype, but not sure I am heading in the right direction.
Code:
function upZips as v (e as p) This function is called after the Excel or Ascii file has been uploaded to the server, but before the data is imported into the target table. 'It allows you to validate the data before it is imported. 'The uploaded file is imported into a temporary .dbf table. Your function can loop over all of the records in 'the temporary .dbf table and make any changes to the data that you want, including deleting records and inserting new records. 'The 'e' object that is passed in contains: 'e.inputFilename - the name of the temporary .dbf table that your function will process 'Your function must set these variables: 'e.outputFilename - the name of the temporary .dbf table that contains the data to be imported into the target table. '(If e.outputFile is not set, then it is assumed to be the same as e.inputFilename) 'e.abort - (Optional) Set to .t. or .f.. If e.abort is set to .t. then the data is not imported and the error message defined in e.errorText is displayed to the user. 'e.errorText - Must be set if e.abort = .t.. The error message to display to the user. 'The passed in 'e' object contains these additional properties: 'e.rv - Request variables 'e.tmpl - pointer to the Grid definition 'e.rtc - a pointer variable that contains run-time calculations 'e.__si - state information 'e.session - session variables 'If you want to send any Javascript back to the browser to execute after this event has completed, you can set this property: 'e.javascript 'EXTREMELY IMPORTANT - The Javascript that is sent back to the browser is executed in the context of IFrame that contains the File Select window. 'Therefore, in order for the Javascript you send back to invoke methods of the Grid object, you must prefix all methods with 'window.parent'. 'For example: window.parent.{grid.object}.refresh() 'Sample validate code - delete records where the quantity is > 10: 'dim t as p 't = table.open(e.inputFilename) ''If you turn on batch begin, scripts that loop over records in a table are significantly faster 't.batch_begin() ' 'dim i as n 'dim count as n 'count = t.records_get() 'for i = 1 to count ' if t.quantity > 10 then ' t.change_begin() ' t.delete() ' t.change_end(.t.) ' 'After deleting a record, the record pointer automatically moves to the next record. ' 'So, no need to advance the record pointer! ' else ' t.fetch_next() ' end if 'next i ' ''Call batch end 't.bach_end() 't.close() t = table.open(e.inputFilename) ''If you turn on batch begin, scripts that loop over records in a table are significantly faster t.batch_begin() ' dim i as n dim count as n count = t.records_get() for i = 1 to count if t.quantity > 10 then t.change_begin() vrZip_code = t.zip_code sql = "" t.zip_code = zip_id t.change_end(.t.) 'After deleting a record, the record pointer automatically moves to the next record. 'So, no need to advance the record pointer! else t.fetch_next() end if next i ''Call batch end t.bach_end() t.close() end function
Comment