NetTalk Central

Author Topic: File Uploads - Creating Child Records  (Read 3859 times)

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
File Uploads - Creating Child Records
« on: March 27, 2014, 12:00:12 PM »
Clarion 8
Nettalk 8
Postgres 9.....

I am doing a file upload off a form called from a table
Customer creates a new record which has the upload button
Chooses file(s) to upload
Clicks the Start button
What I want child are child records (CusVFDtl) to the header record represented by the form (CustVF)
Of course the user has not saved the CustVF record so I don't have the autoincrement ID for the record yet
The child records (CustVFDtl) save just fine but with a link ID of 0

If I break it up into two forms and have the customer create and save the header record and then go back in and upload the files all is good.
I am trying to save that second step - any ideas appreciated.

Maybe just save the record, stay on the form and have the upload button appear at that time, not sure how to do this.

Brian.
Brian

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: File Uploads - Creating Child Records
« Reply #1 on: March 27, 2014, 12:32:53 PM »
Brian,

I've got a similar situation, in fact there are two child files involved. Until now I've taken the approach you mention: save the master record and then have the user go back and add the children, if any.

But I'm in the process of rewriting that particular procedure and I've decided to turn it into a wizard so the user can do it all in one go. In order to facilitate that I've created 3 MEM files, one to hold the master rec and two for the children. When the user calls the form I create a guid and use that as the key in all three files (PK in the master, FK in the children) until the user clicks the save button. At that point I copy the master record from the MEM file to the database and save it. Then I've got the FK to use when I copy from the other MEM files to the database. Finally, I delete the records from the TEMP files.

This means more work for you, but that's upfront and only one time. And the user gets a much better experience when using the program.

As a side effect you may end up with orphan records in the TEMP child tables if the user creates child records but never saves the master. You can either do some house keeping or simply wait till the program gets restarted at which point the temp files go away anyway.

HTH

Peter

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: File Uploads - Creating Child Records
« Reply #2 on: March 27, 2014, 06:25:46 PM »
There are some autoincrement template options that I think will do what you want.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File Uploads - Creating Child Records
« Reply #3 on: March 27, 2014, 08:34:19 PM »
This answer is in 2 parts;

A) on the advanced tab of the form is an option to auto-increment the parent when the form is opened. That way you can add children immediately. Only hassle here is if the form is abandoned, the record remains in the table, so a "completed" field (which you set as the form completes -see priming tab -) is a good idea.

B) I (somewhat contraversially) prefer not to use auto-incrementing numbers but rather to use random ID strings as identifiers. This has a number of advantages - security, cleaner code, database-independent-data -hence scalability, and so on. Disadvantages are managing clustered key in SQL, and the database consuming a little more disk space.

Cheers
Bruce

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: File Uploads - Creating Child Records
« Reply #4 on: March 28, 2014, 10:20:56 AM »
Thanks Peter and Bruce,
I will look at both choices and let you know what I did.
Thanks again.
Brian

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: File Uploads - Creating Child Records
« Reply #5 on: March 28, 2014, 01:37:49 PM »
Tried Bruce's solution with the autoincrement check boxes - had to flag both options
It works just fine for now - Thanks.
Brian