Kah Wee
Posts: 0
Joined: Mon Feb 09, 2015 4:08 pm

retrieve File Name from Files collection

I have been looking through the tutorials, but haven't seen a solution to address this.

I have 2 collections which I am trying to link (Files collection contains the file uploaded, Details collection contains specific details about the same file).

Understand that the best approach would be to
I. Get filename from Files collection
http://prntscr.com/63fhrh

II. Populate the filename into Details collection as a string
http://prntscr.com/63fiop

My approach is:

  1. Invoke upload_service first (to Files collection), then get a response from Files collection for filename. (my mapping so far)
    http://prntscr.com/63fk1q

  2. The response will be mapped to an invisible label.
    http://prntscr.com/63fkr5

  3. Invoke files_details_service (to Details collection). Both files details and filename should be sent in.

    For I., I am having trouble getting a response from Files collection. It is returning "undefined", and I am not able to see what is wrong from browser network.
    http://prntscr.com/63flif

    Am I on the right track, or is there another way to do this?

    Thank you.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

retrieve File Name from Files collection

Hi Kah,

Yes you on the right direction.

But you have wrong response parameters for "upload" service.

See about correct response parameters for "upload" service. And do the same:
http://prntscr.com/63mq4g/direct

So correct mapping after changes should be like this:
http://prntscr.com/63mpqw/direct

Regards.

Kah Wee
Posts: 0
Joined: Mon Feb 09, 2015 4:08 pm

retrieve File Name from Files collection

Thank you Yurii!

Kah Wee
Posts: 0
Joined: Mon Feb 09, 2015 4:08 pm

retrieve File Name from Files collection

I have a followup problem related to 2 & 3.
======

  1. The response will be mapped to an invisible label.
    http://prntscr.com/63fkr5

  2. Invoke files_details_service (to Details collection). Both files details and filename should be sent in.
    ==========

    I have created 2 services, upload_service (upload to Files collection) and create_details_service (upload to Details collection),
    http://prntscr.com/63ovzu

    with both are linked to "Upload" button. Upload_service (via handler) is to be executed first, then create_details_service will be executed subsequently.
    http://prntscr.com/63ow5q

    Theoretically, I should get this result:

  3. Click on "Upload" button, upload_service will occur.

  4. Once file is uploaded into Files collection, a success response with filename will be returned and populated into the invisible label.

  5. create_details_service will be executed.

  6. filename and other details (type, name) will be populated to Details collection.

    However, I found that the execution is in the following order: 1 - 3 - 4 - 2
    Reason I concluded this was because I got the "Success" alert from create_details_service first, before I got "Upload Successful" from the upload handler.
    http://prntscr.com/63oywm

    Therefore, I will always get an empty value returned to Details collection as the invisible label is not populated yet.
    http://prntscr.com/63oy5a - (row 2, value was from previous upload, and I did not clear the value)

    Appreciate your advice on this. Sorry for the long explanation, I hope this gives you enough details for analysis. Thank you.

Kah Wee
Posts: 0
Joined: Mon Feb 09, 2015 4:08 pm

retrieve File Name from Files collection

It's ok, just found out JS is async. Found the solution here.

http://devcenter.appery.io/documentat...

Thanks!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

retrieve File Name from Files collection

Hi Kah,

Glad you solved this question.

Thanks for this update.

Regards.

Return to “Issues”