This topic is locked

Image Not Copied When Copying Records

11/9/2011 11:40:00 AM
ASPRunnerPro General questions
M
MrDerp author

When copying a record I have noticed that all fields are successfully copied apart from images. The filename field is always blank on the copied record - is there a way to ensure that this is populated with the image name from the source record?
I have searched the forum but there has never been a definitive answer to this.
Any help would be greatly appreciated.

Sergey Kornilov admin 11/9/2011

This behaviour us by design - you cannot pre-populate file upload field in the browser. You can only populate text boxes, dropdown boxes, check boxes etc. This means images/files won't be copied when you copy a record.

M
MrDerp author 11/10/2011

Is there definitely no way around this?
Within the CopyOnLoad function, is there anyway I can retrieve the ID of the record I have copied from? My plan is to store this value in a session variable and then use a custom SQL statement in the "After Record Added" event to generate the location of the image from the original record.

Sergey Kornilov admin 11/10/2011

Sure, you can definitely do something like this. Check CopyOnLoad event documentation to see how you can find what record is being copied:

http://xlinesoft.com/asprunnerpro/docs/onload.htm
There are a few questions you need to answer:

  • do you want two records to point to the same image or you need to create a copy of physical file as well?
  • what to do if user decides to upload a new image. You need to make sure you do not override it.

M
MrDerp author 11/10/2011

I have read the documentation but it is very vague. How exactly do I access the ID of the record I am copying from?
"where - WHERE clause that points to the record to be copied. Example: ID=19." - Can you elaborate on this a little?

Sergey Kornilov admin 11/10/2011

Sorry, I don't understand what exactly is not clear.
The typical SQL Query that retrieves one record looks like this:

select field1, field2, field3, ... from tablename where ID=XXX


where parameter contains the value of WHERE clause without the actual word WHERE. You can use it to build your own SQL query and retrieve values from the database.