Skip to content

Custom function with a return type of int, returns a string instead #2568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
Hypersight opened this issue Mar 21, 2024 · 6 comments
Closed
3 tasks done
Labels
closed: not a bug The behavior is correct/expected.

Comments

@Hypersight
Copy link

Has your issue been reported?

  • I have searched the existing issues and confirm it has not been reported.
  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

I have written a custom function that has a return type of int. It passes in a non-nullable list of a custom datatype that has two properties: DocReference (to a Users table) and a datetime field. It also passed in a DocumentReference of the currently authenticated user.

When I attempt to create a condition for a Button element to show, I create a Single Condition, I set the custom function to be the first value to use, i then provide the parameters of the List and the DocumentRef of the Authenticated user.
I leave Available Options as Number Format and Number Format Options as Not Formatted. I then click Confirm to add the first value of my Single Condition.

At this point, it should know that the function has a return type of Int. However, in back in the original Condition window after clicking Confirm, it says that the first value returns (String).

This means that I cannot use comparison types for my Second value of things such as >=, >, <, <= and so on.

Expected Behavior

The custom function is set to return an Int. The custom function returns an Int type parameter, therefore the conditional function should detect it's an Int return type and give me options to select number comparisons.

Steps to Reproduce

  1. Create blank project
  2. Create a Users collection
  3. Create a DataType called PrizeEntry and a parameter called "userRef" which is a reference to a Users collection DocumentRef and a datetime field called "dateentered"
  4. Create a Custom function with a non-null return type of int, it should have a List parameter called "entries" referencing the DataType called PrizeEntry and a DocumentReference param referencing the Users collection
  5. Copy and paste the following code into the function:
 int count = 0;
  for (var prizeEntry in entries) {
    if (prizeEntry.userRef == userRef) {
      count++;
    }
  }
  return count;
  1. Go to the Home page design
  2. Create a dummy Local Page state variable called testEntries, mark it as a DataType of PrizeEntry and as a List.
  3. Create another dummy Local Page state variable called testUser and set it to a type of DocumentReference and the collection Users
  4. Back in the design for Home Page, create a button and enable Conditional and create a Single Condition.
  5. In the Condition for the first value, choose the Custom Function, for the parameters to pass the custom function, choose the two local state page variables you created in Step 7 & 8. Leave all the number formatting default and click Confirm.
  6. At this point, you will see that the condition thinks it's returning a string and not an int. You can also not select a number comparison for the first value and the second value of the condition.
  7. This same issue also happens in a browser (Chrome 122.0.6261.12 on MacOS Sonoma 14.4)

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

IT4slPHlw852j7xZ1rr+bMJ7/SgUKUB5U4JFscsZa0kdB4joPLJ/P87SSFNucM+lY1NhHGGkjk0D+s2Kv4b9IfQBIROuG5s7+LlcdQqXJHq8R66MC86SVHdtGcFWf2qi0cKjhCZSKulidGwH21z6fum/Ex7sGZO/Zwh9f6PHaOI=

Context

This has made number comparison operations impossible. We have an application that rewards users for amount of points earned for example. This bug now breaks this functionality.

Visual documentation

Screenshot 2024-03-20 at 5 26 00 PM Screenshot 2024-03-20 at 5 47 01 PM Screenshot 2024-03-20 at 5 47 09 PM Screenshot 2024-03-20 at 5 47 54 PM Screenshot 2024-03-20 at 5 48 18 PM

Additional Info

This did work previously, but think that maybe it regressed after an update at some point in the last 2-3 weeks. I am unable to say which version was affected.

Environment

- FlutterFlow version: 4.1.33 (Flutter 3.19.1)
- Platform: MacOS Sonoma 14.4 (Mac native app)
- Browser name and version: Chrome 122.0.6261.12
- Operating system and version affected: MacOS Sonoma 14.4
@Hypersight Hypersight added the status: needs triage A potential issue that has not been confirmed as a bug. label Mar 21, 2024
Copy link

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.

@Hypersight
Copy link
Author

Don't close. I am still awaiting someone to triage this issue.

@Ed-Lemaitre
Copy link

Same problem here.

Copy link
Collaborator

Hey @Hypersight thanks for your report. I was able to follow your steps, and I can see you have a small issue. At the end, you have selected "Number Format" on the Available Options, that is the default one. That is formatting your integer to a String. You need to change that to "No Further Changes" for it to remain as an Integer.
I hope this was helpful for you and @Ed-Lemaitre.
Have a great day!

Screenshot 2024-04-09 at 4.30.29 PM.png

@ignalauret ignalauret added the closed: not a bug The behavior is correct/expected. label Apr 9, 2024 — with Linear
@ignalauret ignalauret removed the status: needs triage A potential issue that has not been confirmed as a bug. label Apr 9, 2024
@Ed-Lemaitre
Copy link

Thanks! @ignalauret . 🙇

Copy link
Collaborator

You are welcome, glad it worked. Closing this issue because it got solved, good luck with your project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: not a bug The behavior is correct/expected.
Projects
None yet
Development

No branches or pull requests

4 participants