FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
118 stars 19 forks source link

Unable to assign values to app state variable from a Supabase query #2799

Open manoharraon opened 5 months ago

manoharraon commented 5 months ago

Has your issue been reported?

Current Behavior

Inside an action workflow I have a supabase query which returns a single row of value. Once of the column has a value which is of type List when I try to assign the list to an app state variable which is also of type List it doesnt let me set the whole value as is. When I select update app state variable -->Set value-->> Value to set does not behave the way it should.

Please fix this where users can assign a list to a list variable.

Expected Behavior

assign a list to a list variable in action workflow

Steps to Reproduce

  1. Query a Supabase table and retreive a row by filtering based on unique id.
  2. Assign a value from a column which is of type List to an app state variable which is also of type list. Example if QueryResponse["Column_2"] = ["item1", "item2"] I want to assign ["item1", "item2"] to app state variable which is of type List
  3. No matter what option you select from the "Value to set" sub menu non of the options lets us set the whole list as is

Reproducible from Blank

Bug Report Code (Required)

not a widget

Context

Without this the project workflow is affected since I'm not able to assign a value which is crucial for querying

Visual documentation

error

Additional Info

error

Environment

- FlutterFlow version: 4.1.34
- Platform: Android and iOS
- Browser name and version: Chrome V124.0.6367.61
- Operating system and version affected: Windows

General

Relative to the time the changes were made, data was lost within

When following my steps to reproduce, data loss happens

ignalauret commented 5 months ago

Hey @raomanohar thanks for your report. I just created a Supabase table with a Column of type List called "comments". Then, I created a page, added a Supabase Query that gets only one Row from my table. Also added a Page state variable of type List called "comments".
Then I added a button on the page, added an action to Update Page State, selected my "comments" variable, selected Set Value, and selected my Row and the appropriate Row Field.

Screenshot 2024-04-24 at 11.27.22 AM.png

This seems to work correctly. Please let me know if you are trying anything else here, or if my solution was helpful.
Have a great day!

manoharraon commented 5 months ago

@ignalauret Could you please create a backend query in the action flow editor itself which returns the single row via a variable as shown below instead of making a backend query on the page image then try to store the query output column value into the app state variable(not sure if it makes a difference but yeah please try an app state variable instead of a page state variable) When i select the action flow output to set the variable value I get the below options image

ignalauret commented 5 months ago

I see, the issue you are facing is because you are expecting the UserQueryOp to be only one item. Although YOU know that the result of the query will be only one document because you filtered by id, the editor doesn't know that, so the type of the result would still be a List of Rows, not only one Row.
So, what you are seeing there on the second image are the Available Options you can perform on your List of Rows that the Query returned. From there, you need to implement the logic to get the element you just queried and perform the corresponding actions (like save it to a App State Variable).
Hope I was clear enough to explain why there is no bug here. If you need any more help, please feel free to contact our Customer Support team, they will be able to give you much more help than me. Have a great day!

manoharraon commented 5 months ago

apologies on the delayed response @ignalauret Well I understand the Query response returns a list of lists so the editor doesnt understand that the value is single. Now accordingly when I set value to a string variable I can use the below logic to assign the o/p to the variable. image However, when the app state variable is a list, the available options doesnt even have Item at index please see below. Now Irrespective of what logic I apply from the available option it just doesnt let me assign a list to list. image

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

manoharraon commented 4 months ago

still looking for an solution kindly help

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

manoharraon commented 4 months ago

@ignalauret any update on this?

ignalauret commented 3 months ago

Hey @raomanohar I'm sorry for the late response. Please let me know if you were able to figure it out, or if you would like me to review it again.

manoharraon commented 3 months ago

@ignalauret unfortunately not. i would be grateful if you could please help with that

Alezanello commented 2 months ago

Hello @raomanohar !

First of all, I apologize for the delay in our response. We are working to improve our support so you can continue with your development smoothly.

On another note, could you please provide a Bug Report Code from the page of your project where you are experiencing this issue? This will help us investigate further.

image

Thank you for your understanding.

Best regards, Azanello

sabatage3 commented 2 months ago

I'm having this exact same issue, but it is not related to Supabase only. This is a Flutterflow feature (or the lack thereof). You can't extract a list within an item inside a list. Flutterflow doesn't let you get into the item in the list to extract the field with the list; it assumes by default that there are no lists inside.

The only workaround would be to create a custom action that extracts the first item of the list and then use it normally. However, this isn't a very good solution since you are duplicating the data. I suppose it depends on how many times you are planning to make that query.

Alezanello commented 2 months ago

Hey sabatage3!

Could you please create a new issue here on GitHub describing this situation and replicating it from a blank project? This will help us look into it and prioritize it accordingly.

Thank you!

manoharraon commented 2 months ago

@Alezanello there is no bug as such. As sabatage3 mentioned Flutterflow does not let us extract values from a list. All I am looking for is assigning a list value to an app state variable which is also of type list.

Alezanello commented 2 months ago

Hello!

I would like to take a deeper look into your project to better understand and replicate the issue. For that, I need you to generate the bug report code as shown in the image I sent the other day.

Please generate the bug report code on the page where you need assistance. This will allow me to review the logic of how you are calling and assigning the list.

Alezanello commented 2 months ago

Hello,

I was able to replicate the issue and now understand your goal better and the frustration of not being able to achieve it. I'll forward this to the engineering team to address it, but in the meantime, I've found a workaround that might help. It's a bit tricky, but I'll explain it step by step.

This solution works if the query result from Supabase is a single row. If it’s a list of rows, a more complex workaround is needed, but it’s still achievable. Let me know if this works for you.

  1. Create an Integer variable in PageState named "Counter." Unmark "nullable" and set the initial value to 0.
  2. Create a Loop Action in your Action Chain where you want to add the list of strings to the appState list of string variables.
  3. Set the Loop Action condition to "Counter is Less Than" and for the second value, select the List Variable of your Supabase Query Result, then select "Number of Items."

    image.png
  4. Inside the Loop, create an Update App State action. Select the AppState variable and set the Update Type to "Add to List."
  5. In the "Values to add," go to the List of Strings of the query result, select "Item at index," then "Specific Index," and set the index value to the Counter variable of the Page State.

    image.png
  6. Inside the Loop, after the Update App State action (not outside the loop, be careful with that), select Update Page State, select the Counter variable, and set Increment/Decrement to 1.

    image.png

This will add all your query list of string results to the appState list variable.

Let me know if this workaround works for you!
This is the Loop Action completed:

image.png

Best regards,
Azanello

Alezanello commented 2 months ago

After all this explanation i just checked and you can assign the List of Strings variable from the Supabase Query to the List of String of the AppState if the Supabase Query is setted as Single Row (Based on your query with the unique id, this could be your case, so check that your Supabase Query is set as Single Row and not Lists of Rows)

image.png image.png