# Reference smart field undefined in success messages

**URL:** <https://community.forestadmin.com/t/reference-smart-field-undefined-in-success-messages/3880>\
**Category:** Help me!\
**Created:** [December 10, 2021, 11:30am UTC](https://community.forestadmin.com/t/reference-smart-field-undefined-in-success-messages/3880 "2021-12-10T11:30:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)\
**Post date:** [December 10, 2021, 11:30am UTC](https://community.forestadmin.com/t/reference-smart-field-undefined-in-success-messages/3880/1 "2021-12-10T11:30:59Z")

</div>

In my collection, I have a reference field which is a smart field, called title :

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/9/94a798353e3fdad4aff5f23f26d18898b62a2f31.png)

this title smart field is pretty straight forward :

```javascript
{
    field: 'title',
    type: 'String',
    get: place => `${place.sergicIdFull} - ${place.displayName}`,
    search: (query, search) => {
      const split = search.split(' ');
      const searchCondition = {
        [Op.or]: [
          { 'sergic_id_full': { [Op.iLike]: `%${split[0]}%` } },
          { 'sergic_id_full': { [Op.iLike]: `%${split[1]}%` } },
          { 'display_name': { [Op.iLike]: `%${split[0]}%` } },
          { 'display_name': { [Op.iLike]: `%${split[1]}%` } },
        ],
      };
      query.where[Op.and][0][Op.or].push(searchCondition);
      return query;
    }
  }

```

and BTW, in my places model :

```javascript
const Places = sequelize.define('places', {
    displayName: {
      type: DataTypes.STRING,
      defaultValue: "",
      allowNull: false,
    },
    ...
    sergicIdFull: {
      type: DataTypes.STRING,
    },

```

When I Edit any record, after having clicked Save, I get the following message:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/9/96d9923d10e915871a1322cb1e9149cd73e2581e.png)

So I changed my reference field to another one:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/7/76b91359df702a34cf47d7e03ad06d3fe1593a60.png)

And it’s now displayed correctly:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/3a2ea1e304282d92cc220f2543490c488c70bc16.png)

---

<div class="post-metadata">

**Author:** ![anon79585656](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon79585656](https://community.forestadmin.com/u/anon79585656)\
**Post date:** [December 10, 2021, 3:06pm UTC](https://community.forestadmin.com/t/reference-smart-field-undefined-in-success-messages/3880/2 "2021-12-10T15:06:32Z")

</div>

@JeremyV

Thank you for sharing this.

Using the snippets from your message, I cannot reproduce the issue. The update toaster properly display my SmartField value when I set it as reference field.

Could you tell my what version of `forest-express-sequelize` (or other forest package) you are using?

Did it stop working? Or is this the first time you are using this field as the reference field?

Maybe you could try to reproduce the issue with another SmartField in another collection?

Thank you

---

<div class="post-metadata">

**Author:** ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)\
**Post date:** [December 10, 2021, 3:09pm UTC](https://community.forestadmin.com/t/reference-smart-field-undefined-in-success-messages/3880/3 "2021-12-10T15:09:24Z")

</div>

> [@anon79585656](#):
>
> Could you tell my what version of `forest-express-sequelize` (or other forest package) you are using?

“forest-express-sequelize”: “^7.12.3”

> [@anon79585656](#):
>
> Did it stop working? Or is this the first time you are using this field as the reference field?

I have the feeling that it was working before but I’m not 100% sure.

> [@anon79585656](#):
>
> Maybe you could try to reproduce the issue with another SmartField in another collection?

I’ll try that.

---

<div class="post-metadata">

**Author:** ![anon79585656](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon79585656](https://community.forestadmin.com/u/anon79585656)\
**Post date:** [December 10, 2021, 3:34pm UTC](https://community.forestadmin.com/t/reference-smart-field-undefined-in-success-messages/3880/4 "2021-12-10T15:34:09Z")

</div>

Thank you for the details @JeremyV,

I changed my project to use version 7.12.3, still working on my end.

For the record, here is my model file `models/item.js`:

```javascript
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  const Item = sequelize.define('item', {
    value: {
      type: DataTypes.STRING,
    },
    name: {
      type: DataTypes.STRING,
    },
    type: {
      type: DataTypes.STRING,
    },
  }, {
    tableName: 'item',
    timestamps: false,
    schema: process.env.DATABASE_SCHEMA,
  });

  return Item;
};

```

and my SmartField definition `forest/item.js`:

```javascript
const { collection } = require('forest-express-sequelize');

collection('item', {
  actions: [],
  fields: [{
    field: 'smart',
    type: 'String',
    get: item => `${item.value} - ${item.name}`,
    search: (query, search) => {
      const split = search.split(' ');
      const searchCondition = {
        [Op.or]: [
          { 'value': { [Op.iLike]: `%${split[0]}%` } },
          { 'name': { [Op.iLike]: `%${split[1]}%` } },
        ],
      };
      query.where[Op.and][0][Op.or].push(searchCondition);
      return query;
    }
  }],
  segments: [],
});

```
