Issues with upload component

What are you trying to do? (please be as specific as possible and include relevant screenshots, code snippets)

I’m using a upload component that when used will
1.- create a row in one of my tables, one of the cells will be a random generated uuid.
2.- upload the file to one of my supabase buckets, using the id or name of the file as the path (previously filled in the row)
3.- update the value of a state so I can see if the path was filled correctly.

Issues:
1.- no matter what I do, in the first interaction which is creating the row it duplicates it, I’ve traid setting the upload from zero in a completely different page and it always creates a duplicate row, I do have the following filter on all the interactions from this field: ($state.upload.files.length > 0) I’ve also tried not updating all queries after the row creation, the duplication still happens.

2.- when I upload the file to the bucker I select the las .file_name on the table as the path, which was created in the previous step using the following formula: $queries.filesTable.data[0]?.file_name
For some reason it always gets the previous upload which would be the third cell in the table due to the duplication, or the second if that problem didn’t exist, in other words, when this step fetches the table is does not use the last updated information. However if I give the same value ($queries.filesTable.data[0]?.file_name) to a state variable, it automatically updates, so plasmic is reading the correct information, only in the interactions is ready the second to last.

this step is after the row was already crated and refreshed so it should fetch the data correctly.

what I’ve tried:

using the following formulas: $queries.filesTable.data[$queries.filesTable.data-1]?.file_name $queries.filesTable.data[$queries.filesTable.data.length-1]?.file_name using a “Refresh data” interaction after creating the row and before uploading the file to the bucket. does not work It will still use the second to last.

What are the reproduction steps? -

-(duplication) creating a new upload field with a limit of files of 1. Setting up a “use integration” interaction with supabase, create row and any of the refresh queries.
-(wrong fetch issue) the step before as the first interactions block, the second block a “use integration > Upload file > when files length is greater than one.

setup: file path: $queries.filesTable.data[0].file_name or the other formulas I shared above.
content: $state.upload.files[$state.upload.files.length - 1]?.contents
Type: $state.upload.files[$state.upload.files.length - 1]?.type

(here the file path will not use the last row in the table it will use the next to that one, 3rd)

i’ve also recorded the issue in case It is a little confusing: IMG_4505.MOV - Google Drive

Thanks.

Hello @arturo_rabago, thank you for the detailed explanation. Can you share your project id so I can investigate further?

Hi Sarah ! sure, I couldn’t find find in the docs how to share the id but here is a link sharing the project: Plasmic

I will leave the upload button in the page called “New Campaign”, also two new issues have arised,

1.- I’m not able to create new pages, I get a message saying “could not save your project, the last action you took resulted in an invalid state, we are looking into it”

This started happening right after I posted the previous issue, I tried using other browser and computer and its still happening, the funny part is that every change is actually saved contradicting the message, however it just wont let me create a new page.

2.- I’m using a Custom SQL query in the “Configure user properties operation” to get a table in the customProperties tab inside the user properties. this user table will give me the user table but add a second row if the user is a member of two companies. example: my email is used as a designer in one plasmic project from x company but I’m also set up as a plasmic developer in Y company, which is what I’m trying to achieve with my app. (Have company profiles with users inside)

that being said, when I preview the chart both rows are shown correctly as it should. as shown here.

however when I actually try to select between those rows the customproperties tree will only show the first row or object:

since the app I’m trying to build is company based, all url paths begin with /[company_username]/[Other ids] I want plasmic to be able to get that dynamic data while also checking that the user is a member of that company, I also thought about just adding that row to the users table but what if like in my previous example the user is a user of two companies, please, if you have any suggestions on how to solve this natively in plasmic let me know.

Thanks for the help.

Hello @arturo_rabago, thank you for the detailed explanation of all issue.

  1. Re (Upload duplication): The onFileUploaded interaction is triggered twice, once with “uploading” status, and the second time with “done” status. You can use this condition in the When expression to ensure your actions run when the file has done uploading On file uploaded step: $state.upload2.files.every(f => f.status === "done")

  2. Re (path name set to previous uploaded file):

    • You can set a “When” condition on the Update pathname step: $steps.supabaseUploadFile. This will ensure that the supabaseUploadFile step is completed before the pathname state is set.
    • Set the Supabase Upload step’s “When” condition to $steps.postgresGetList to ensure that it runs after the previous step has been completed.
    • In the Supabase storage operation, set the file path to use the previous step’s results: $steps.postgresGetList.data[0].file_name

For more information on $steps and using the results from previous steps, check out our docs here: Interactions and state reference | Learn Plasmic

Re (Could not save project): Can you please confirm if you recently made any changes to the Page Layout component?

We have identified what the issue is with the new page creation crashing studio. It happens because your Page Layout component has a state with external access. We are working on a fix, but in the meantime, can you set the external access on the “Signed in company” state to false? That should momentarily resolve your issue and let you create new pages.

Alternatively, you could use the Data Provider component from the Insert Panel and expose the signedInCompanies state. That would ensure all pages using the PageLayout have access to this variable:

ok great all will try all the suggestions,

As per the signed in company, I’m doing this to solve the idea of having company profiles with their user staff, maybe I dont need to have the variable in the page layout but again I don’t know if there is a better way to have that kind of structure natively on plasmic or in the user properties, do you have any suggestions, best practices or documentation I could check ? I don’t think I’m the first user doing something like this in plasmic right ?

Also is there a way to solve the custom properties issue that is not showing both rows of the queries? that may also solve the need to have the variable on the page layout.

thank you!

Re (SQL response): You should be able to find the array of query results inside userCompany (see the screenshot below):

I believe the answers above should resolve your queries regarding the Upload component and the other issues. I’ll close this ticket now, so any new questions can be added as separate topics for better organization and easier searchability in the forum. Looking forward to hearing if the answers helped solve the problems.