Skip to content

error using field names containing "_" in custom action #1282

@DZipfel1

Description

@DZipfel1

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

When i use a field name containing "_" in field name like caller_id (from "caller" firestore Schema) or display_name (from "user" firestore Schema) in my custom action, i get the error "The getter 'caller_id' isn't defined for the type 'CallsRecord'." when compiling.

When i use a field name not containing "_" in field name like status (from "caller" Schema) or uid (from "user" Schema) in my custom action, i get no errors

Expected Behavior

When i use a field name containing "_" in field name like caller_id (from "caller" firestore Schema) or display_name (from "user" firestore Schema) in my custom action, it shall be compiled without errors.

Steps to Reproduce

  1. create firestore "calls" Schema with field name "caller_id" containing "_"
  2. enable "contacts" permission
  3. create custom action with "document" List as "calls" document type as argument
    example code:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:contacts_service/contacts_service.dart';

Future<List<CallsRecord>?> searchNames(List<CallsRecord>? callList) async {
  if (callList == null) {
    return null; // or handle the case where callList is null
  }

  // Get all contacts from the device
  List<Contact> contacts =
      await ContactsService.getContacts().then((value) => value.toList());

  // Define a function to search for the matching displayName of a phone number
  String? searchName(String? phoneNumber, List<Contact> contacts) {
    // Loop through all contacts to find the matching phone number
    for (var contact in contacts) {
      if (contact.phones != null) {
        for (var phone in contact.phones!) {
          if (phone.value == phoneNumber) {
            // Return the displayName of the matching contact
            return contact.displayName;
          }
        }
      }
    }
    // If no matching contact is found, return null
    return null;
  }

  // Loop through all calls in the callList
  for (var call in callList) {
    if (call.caller_id != null) {
      // Replace the caller_id with the matching displayName
      call.caller_id = searchName(call.caller_id, contacts);
    }
  }

  // Return the updated callList
  return callList;
}
  1. use caller_id of argument list in custom action

Reproducible from Blank

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

Bug Report Code (Required)

ITFXl+fl05N2oshE+aXhKMJsnj0wGUwbUOc7j9VEGAsjCeKvP4YiYPelU1htYuqHYWNIHVSWjk01w87QkuDDCMY7GxSVbIRlz6gAUxDjeH2RRaqoELmOf3JADcVVIFS45MOznCV4GPdZWloE1Du2Deq+b3qCf9qOYwx5e6fDbOY=

Context

I want to replace caller_id of a list by names of phone contacts using one action for fetching the caller list and another action to look in phone contacts if the caller ID exists ther to then replace the caller_id by the phone contact name in the existing list.

Visual documentation

firebase Schema flutterflow_code

Additional Info

i also tried to run the app by excluding action from compiling in editor, but then also ran into the same error.
compilation error

Environment

- FlutterFlow version: 1.1.96
- Platform: MacOS Desktop
- Browser name and version: Chrome 115.0.5790.114
- Operating system and version affected: MacOS Ventura 13.4.1

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions