Skip to Main Content

Is there a way to get the wwv_flow_files (apex_application_files) "ID" following javascript upload?

Simon_GaddDec 4 2020

Hello folks.
I've been away from APEX for a while but I'm back on-board with a project that is pushing my knowledge to the max.
We have an app which is built on-top of the APEX Packaged Survey Builder application.
We have modified the javascript to allow us to upload a file to wwv_flow_files (apex_application_files)
My challenge is that I need to get the unique ID which is automatically assigned to the uploaded file that is succesfully saved into wwv_flow_files (apex_application_files).
I have had a trawl through the documentation (ORDS) but can't find a way to get it.
Does anyone have any ideas?
We're using APEX v20.2.0.00.20 hosted in the cloud.
This is the .js function that is invoked and succesfully saves the file. I then have an AJAX Callback on the APEX page which I want to use to move the file from wwv_flow_files (apex_application_files) to it's permanent storage in a dedicated table for the application.
function uploadFile(pFileIndex) {
var fileInput = document.getElementById('q1');
var file = fileInput.files[0];
var formData = new FormData();
formData.append('p_flow_id', encodeURIComponent(flowId));
formData.append('p_flow_step_id', '99');
formData.append('p_request', 'APPLICATION_PROCESS=attachment');
formData.append('p_arg_names', 'P99_RESPONSE_ID');
formData.append('p_arg_values', encodeURIComponent(responseId));
formData.append('p_arg_names', 'P99_Q_ID');
formData.append('p_arg_values', encodeURIComponent(qKey));
formData.append('p_arg_names', 'P99_FILE_NAME');
formData.append('p_arg_values', file.name);
formData.append('p_arg_names', 'P99_MIMETYPE');
formData.append('p_arg_values', file.type);
formData.append('p_arg_names', 'P99_QUESTION_NUMBER');
formData.append('p_arg_values', file.number);
formData.append('p_instance', sessionId);
formData.append('file', file);
var xhr = new window.XMLHttpRequest();
// Add any event handlers here...

xhr.open('POST', sbURL, true);
xhr.send(formData);

}
Any help or pointers much appreciated.
Cheers
Simon

Comments
Post Details
Added on Dec 4 2020
0 comments
33 views