NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: broche on March 10, 2018, 12:38:22 AM
-
Hi All,
CL 10
NT 10.18
STheory 2.73
Doing FIle Uploads and trying to
1) Save the uploaded file to another location
2) Create a record for each file attached to the parent by a staff ID
Works fine on single uploads
Works fine on multiples if I click start on each file
If I click start on multiple files
- Saves each file where I want it
- Creates the first child record then wloses the staffID and does not save the record.
Code as follows:
SaveFile::st:UploadCerts Routine
data
! Start of "Save File"
! [Priority 5000]
! End of "Save File"
code
! Start of "Save File"
! [Priority 5000]
IF p_web.GetValue('nosave') <> 1
Clear(ECT:Record)
ECT:staffid = p_web.GSV('st:staffid')
ECT:CertLocation = p_web.GSV('st:UploadLocation')
ECT:CertName = str.FileNameOnly(p_web.GSV('st:UploadCerts'))
Access:empcerts.Insert()
st:UploadCerts = clip(p_web.GSV('st:UploadLocation')) &'\' &ECT:CertName
p_web.SSV('st:UploadCerts',st:UploadCerts)
!MESSAGE(p_web.GSV('st:staffid')) -- this is correct
END
! End of "Save File"
p_web.SetSessionValue('_save_st:UploadCerts',st:UploadCerts)
p_web.SaveFile('st:UploadCerts',st:UploadCerts)
! Start of "Save File"
! [Priority 5000]
! End of "Save File"
Thanks in advance
Brian.
-
I'm seeing the same thing on build 10.18.
It had been working for years and stopped working.
Do not know when it stopped.
Don
-
Thanks Don, yes it seems to be associated with 10.18?
I think I understand the flow of the process. Maybe it's a thread thing?
-
Hi Brian,
When you do a multi-select and "start" then all the files are sent up _at the same time_.
You'll see this in your log.
So you need to view this code with the thought that there are lots of procedures running this same code all at the same time.
Apart from the MESSAGE statement (always a REALLY bad idea, and a sign that you are not using Debugview...)
>> Creates the first child record then loses the staffID and does not save the record.
does not save _which_record? EmpCerts? or the parent record?
cheers
Bruce
-
Guilty as charged on this one. Will check with debugview.
Does not save the EmpCerts Record. The Parent record (staff) already exists before all this happens.
Thanks.
-
If I conduct a multi file upload, it uploads the first file selected to the correct directory. The other selected files are not uploaded.
However, all of the files' table records ARE correctly created.
Don
-
Hi Brian,
Along the line of what Bruce said. You need to "save" the value of st:staffid into a safe unused session variable, prior to the upload commencing. Then use that saved value to prime your ECT record.
Because, if your uploads can take some time your user might leave this screen and do something else that will change the value in your st:staffid session variable. If they do that your uploads
(or some of them) will arrive for the wrong staff member, which can prove very unsatisfactory.
That said, I don't think its your actual problem here. Unless you have other code on this page which changes the st:staffid, in which case its probably your problem.
Regards
Bill
-
Thanks Bill, when I prime the update using Loc:StaffID it works just fine. Saves correctly and creates all records as desired.
I am using autonumbering on the st.StaffID field and not sure where or when I can grab that ID.
Thanks.
-
If you are creating child records (image records) before the parent record has been inserted, then the ID field would not yet be set. So you have to force the form to Insert when the form is opened. This is done on the form settings, advanced tab, "Auto Inc even if not necessary". Then the staff ID is in the session value.
cheers
Bruce
-
Thanks Bruce, great - yes should have remembered that one, heard it in your webinars enough.