Skip to content

Newly created custom functions save without error but disappear after refresh (existing functions save fine) #7331

Description

@dollydesign

Can we access your project?

  • 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'm losing custom functions in this project and I've narrowed down when it happens.

If I open a function that already exists and edit it, everything works normally. I made a small change to concernLabel, compiled it, saved it, and it stuck.

But when I create a brand new custom function, it compiles fine and saves with no error message — and then it's simply gone after I refresh. It's not in the list at all. That's happened three times now: floorSuggestV2 today, and groupByCategory and zzTestReturn yesterday. I've waited several minutes and refreshed again in case it was a sync delay, but it never comes back.

There's a second problem that may or may not be related. I duplicated an existing function to make floorSuggestCopy. It passes the code check (green tick), but when I click Save I get "The function is empty or cannot be parsed. Make sure not to modify code outside of the designated area." I only edited inside the designated area. To test it I commented out the two lines that were the only new thing in the body, which left it essentially identical to the original function that works fine — and it still gave the same error. So it doesn't seem to be my code.

Project is Pink Coach, branch feature/sales-closeout. Let me know if you need access to look at it directly.

Expected Behavior

A new custom function that compiles and saves without error should persist — it should still be in the custom functions list after a page refresh, exactly like edits to existing functions do.

Steps to Reproduce

Open the project on branch feature/sales-closeout
In the Custom Functions panel, click + to create a new function
Give it a name, set a return type, and add arguments
Paste a valid function body between the MODIFY CODE lines
Click the compile/check button — it passes, no errors
Click Save — saves with no error message or warning
Hard refresh the browser (Ctrl+Shift+R)
Open the Custom Functions panel

Result: the new function is not in the list. Waiting several minutes and refreshing again doesn't bring it back.

Control: repeat the same edit/compile/save cycle on an existing function (e.g. concernLabel) and the change persists correctly after refresh.

Reproducible from Blank

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

Bug Report Code (Required)

IT40sPHY4YV+muYC47rIKvZHhiIgKUs1W+YNoOpBaCsofePrOpkAf8/7UFtUOMOmd2Nqf2KahXwX/Mrpv/zxUfk4PReufoQ6+KVQbj3JTlmuR7HXCJS3b0BCDZpnGHKF4bus3SMlXc1YS1497UymPeiAaDTANYzODFY3QuaeXdeK2SrDX1iXc2URm05KZDPz

Visual documentation

import 'dart:convert';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart' as timeago;
import '/flutter_flow/custom_functions.dart';
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/auth/supabase_auth/auth_util.dart';

/// Pure offline suggestion engine.
///
/// Takes the guest's concerns plus the cached catalog and concern map, and
/// returns products grouped by concern (one SuggestionGroup per concern),
/// with products resolved from cached catalog. Applies the age>40 Volu-Firm
/// Set rule. No query — runs entirely on cached App State so it works with no
/// wifi.
List floorSuggestCopy(
List concerns,
List catalog,
List concernMap,
int? age,
) {
/// MODIFY CODE ONLY BELOW THIS LINE

// Real Volu-Firm Set (never the junk 8476428b one)
const voluFirmSetId = '0800c10e-79a2-4cf4-9925-a220befc7ca1';

// Build an id -> ProductItem lookup from the cached catalog
final byId = <String, ProductItemStruct>{};
for (final p in catalog) {
if (p.id.isNotEmpty) {
byId[p.id] = p;
}
}

final over40 = age != null && age > 40;
final voluFirm = byId[voluFirmSetId];

final groups = [];

// One group per guest concern, in the order the concerns arrive
for (final code in concerns) {
ConcernMapItemStruct? mapRow;
for (final m in concernMap) {
if (m.code == code) {
mapRow = m;
break;
}
}
if (mapRow == null) continue;

final products = <ProductItemStruct>[];
for (final pid in mapRow.productIds) {
  final prod = byId[pid];
  if (prod != null) {
    products.add(prod);
  }
}

if (over40 && voluFirm != null) {
  final alreadyIn = products.any((p) => p.id == voluFirmSetId);
  if (!alreadyIn) {
    products.add(voluFirm);
  }
}

if (products.isEmpty) continue;

groups.add(
  SuggestionGroupStruct(
    concernCode: mapRow.code,
    concernLabel: mapRow.label,
    products: products,
  ),
);

}

return groups;

/// MODIFY CODE ONLY ABOVE THIS LINE
}

Environment

- FlutterFlow version: most recent 
- Platform:
- Browser name and version:
- Operating system and version affected:

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions