This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Upload file and read into collection

Hi Experts,

I have a file upload node using which I upload a file to a server. I think trigger an event and read that data into a table. So far so good. 

I now need to load this data into a collection. To do this, I though of using a while loop with the condition

0 = select count() from BulkUploadUsers

Inside the loop, I load the collection.

I thought the collection will be loaded in one go, however the while loop quits after it loads the first object.

 

Is there some way to effectively give feedback from the backend to the front end that it can now load the collection?

 

Thanks

Kin

  • Hi

    What you can do is to write a script that will read in all files in a directory an return them as a semicolon separated string. So, you are able to call this script after uploading a file  to fill your collection with the option "Fill from expression". To get a result set for the collection you need to split the semicolon separated string by using the built-in function Split().

    For further details see the following printscreen:

    Ensure that you also need to write a DialogScript function that will be able to read in all files from a directory. The function should have one parameter, so that you are able to submit the full quallified path of the directory. The return value should be a semicolon separated string. If you want to upload your files to a file share in your company network you have to ensure that your ApplicationPool user have the appropriate access rights to this share. Otherwise the access via your web frontend will fail (in this case it is recommended to use an own AD account for the ApplicationPool identity).

    -
    Regards
    Sven

  • Hi Sven,

    Thanks for your reply. I'm probably being stupid here but I'm not sure how I can read the data into my collection. The file uploaded has a list of users which I map to a uid_person in the table where I import the file. I now need to read data from this table into a collection. The idea is a user can upload a list of persons to do multiple requests instead of selecting users by hand.

    Thanks
    Kin
  • Just to clarify, I have implemented the functionality where a file is uploaded and the data from the file is imported into a custom table. I now need to read the data from this custom table into a collection, the issue is I don't know how to check if the table in the backend is "ready" to be loaded into a collection.
  • Ok, my mistake I was to fast by giving an answer. The question is, how do you load the data that you have uploaded into your backend table?
  • Yep, I was thinking of creating another table where I insert a record after the import is done. Then in the while loop I'll query this new table, and when the record appears I'll exit the while loop and load the collection. Of cos I'll change it to handle concurrency but as an idea do you think this will work?
  • Can you tell me how do you load the file content into the table after you have uploaded your file?
  • Just tried this and it works! Here's a summary of how I did it:

    1) Create 2 tables (t1 and t2), one to store the data in the uploaded CSV file, another to store the status of the last import of that file
    2) After uploading the file, trigger the event to import the data into t1. After the import, insert an entry into t2 and update a status column.
    3) In the while loop, loop until count = 0 for the t2 collection. Inside the loop, load the t2 collection with a corresponding where clause
    4) After the while loop, you can now load t1 and everything should work

    I also added a column in both tables for CCC_FileName which allows this to be run concurrently as long as the generated file name of the upload is unique (Easily done)