[Multiple File Upload] Multiple file appear in demo

[Multiple File Upload] Multiple file appear in demo

  
Forge Component
(31)
Published on 2016-09-06 by -
31 votes
Published on 2016-09-06 by -

Hi, I am trying to use Multiple File Upload extension in Forge. But after uploading, the files can't display in file table. They display in the multiplefile uploading demo page. 


The screenshot is my application. After uploading, there is no file in the table but it appears in the MultiFileUpload demo.

I think it's due to the FileProcessURL property in the extension. But I am not sure. And I don't know how to change the value in this property as well.


Could you please help me with this? Thanks. 

Please share sample oml file.

Suraj Borade wrote:

Please share sample oml file.

There are just too many things in the page. In order to do exercise, I made two different types of upload. Second one is the MultiFile upload. And for the first ordinary upload, I will get duplicated docs after uploading multiple files to the same doc. Could you also help me with that? Thanks very much!!!!



Hi Nina.

The file upload component does not store the files on your entity. It stores in its own entity, called UploadCache. You already have a reference to that entity on your example.

What we usually do is to copy those files from that UploadCache table to our application table (in your case the Upload table). This should be done when you "save" the files. In your case, it would depend on whether you want the uploaded files to be saved immediately after uploading, or when the user clicks the Assign button.

To copy the files from one table to the other, you can query the UploadCache, iterate the results, and create the corresponding records on Upload table. Or you can do in a SQL query (by using INSERT and SELECT together) to avoid transmitting the binaries from and back to the database.

In that process, you would usually filter by a unique SessionId. Think that many users could be uploading files at the same time. All of them would end up in the UploadCache entity, and you would not be able to distinguish them. You should generate a unique session id on the Preparation to correlate the cached binaries with those that your user uploaded. You can use GenerateGuid from the System module, you'll have to add that as a reference.

Leonardo Fernandes wrote:

Hi Nina.

The file upload component does not store the files on your entity. It stores in its own entity, called UploadCache. You already have a reference to that entity on your example.

What we usually do is to copy those files from that UploadCache table to our application table (in your case the Upload table). This should be done when you "save" the files. In your case, it would depend on whether you want the uploaded files to be saved immediately after uploading, or when the user clicks the Assign button.

To copy the files from one table to the other, you can query the UploadCache, iterate the results, and create the corresponding records on Upload table. Or you can do in a SQL query (by using INSERT and SELECT together) to avoid transmitting the binaries from and back to the database.

In that process, you would usually filter by a unique SessionId. Think that many users could be uploading files at the same time. All of them would end up in the UploadCache entity, and you would not be able to distinguish them. You should generate a unique session id on the Preparation to correlate the cached binaries with those that your user uploaded. You can use GenerateGuid from the System module, you'll have to add that as a reference.

Hi Leonardo,

Thank you for your reply. So you mean the files can't appear in the table which I created if I didn't copy UploadCache table to my upload table? I just changed the source record of my table to GetUploadCache. 

But after uploading, the file didn't show up in my table. It appears after refreshing page. How can I make it show up in my table after uploading?

Thanks. 


Hi Nina.

Did you refresh the query, before refreshing the table via ajax?

Leonardo Fernandes wrote:

Hi Nina.

Did you refresh the query, before refreshing the table via ajax?

Hi Leonardo,

I refreshed query in the page action. But it still didn't appear in the table.


Nina, you are refreshing the UploadTable, but in your previous screenshot you showed that the table listing the upoaded files was called FileTable. I'm putting your screenshots here again so you can see the difference. Maybe you just refreshed the wrong table?


Leonardo Fernandes wrote:

Nina, you are refreshing the UploadTable, but in your previous screenshot you showed that the table listing the upoaded files was called FileTable. I'm putting your screenshots here again so you can see the difference. Maybe you just refreshed the wrong table?


Hi Leonardo,

Thanks for your help! It's true that I refresh the wrong table. Thank you. 


Hi Nina,

If your issue is resolved, please mark the solution.

Thanks,

Suraj

Hi Leonardo,

There are something wrong with Multiple file upload. I created in the page. 

1) After submit this page ( task entity), the table should be empty after I open a new task page. But the files are still exist in the table. How can I make it empty after I submit the task?

2) If I upload multiple file to the task, after I submit the task, there will be multiple amount of tasks showing in the task table. They are exactly the same. 

 Here is the action in the submit button:


Can you help me with these problems? Thanks!!

Hello Nina. Here are my answers:


1) After submit this page ( task entity), the table should be empty after I open a new task page. But the files are still exist in the table. How can I make it empty after I submit the task?

You need to use the SessionId for that. I tried explaining in some previous message, but hopefully it will be clearer now.

The trick is making your SessionId a unique text. This SessionId will be stored alongside your files, and if it's unique it will allow you to distinguish which files belong to your new task, and which files don't. Here's a recipe of how to do that:

a. Use the GenerateGuid action in the preparation. This is an action from the System module, you might need to add a reference to it. The GenerateGuid always generates a unique string.

b. Use the output of the GenerateGuid as the value of the SessionId input to the MultipleFileUpload block.

c. If you want to display a table with the files, make sure that you add a filter on the query: TEMP_UPLOADED_FILE.SessionId = GenerateGuid.Guid. This will make sure that you won't show other files, only those that were uploaded on your screen.

d. On the save action of your screen, you can query the TEMP_UPLOADED_FILE using the same filter to obtain all the files that were uploaded by the user. Use this query to copy all the files to your business tables.


There is one technicality if you use submit buttons on that screen. Basically a submit button will run the preparation again, and generate a new Guid. You can avoid that from happening, but the easiest way is to make sure that the screen only has ajax buttons and links.



2) If I upload multiple file to the task, after I submit the task, there will be multiple amount of tasks showing in the task table. They are exactly the same.

That would depend on how you are doing your query. But, as a rule of thumb, if duplicate objects are appearing, it must be because you are doing a JOIN with a table that has multiple entries for that object.

I would guess that you have a JOIN from Task to a table storing the files and, when you have multiple files for the same task, this makes the same task appear multiple times. The solution would be to remove the join.



PS: could you tell me how can I have a character with a watermelon hat, eating watermelon, inside my Service Studio? That's the coolest thing I have ever seen.

Hi Leonardo,

Thank you for your patient reply! I really appreciate that!! I tried by myself but it didn't work. If you have time, could you please help me to fix these two problems in my application? That would be really helpful!! 

And for the watermelon thing, it is just a IME (Input method editor) of Chinese. Lol. The watermelon is the skin of that IME and I just include that when I capture the screen. LOL. 

Solution

Hi.

I made a few changes to the screen. I wasn't able to test it, but it should get you started.

The GenerateGuid part was ok. But you need two lists: one for the existing attachments, and another for the new attachments, because they are stored in two different tables. You were also not refreshing the list of attachments in the Refresh action.

I have included the two lists, and reviewed some logic that you have in the Preparation and in the Assign action. I made a couple comments there, you should read them.

Let me know if you need further help.

Solution

Hi Leonardo,

Thank you very much for your help!! I really appreciate that!!


Nina