# Smart field does no appear in dev

**URL:** <https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962>\
**Category:** Help me!\
**Created:** [July 12, 2022, 2:48pm UTC](https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962 "2022-07-12T14:48:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jules\_Truong](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jules_truong/32/4430_2.png) [@Jules\_Truong](https://community.forestadmin.com/u/Jules_Truong)\
**Post date:** [July 12, 2022, 2:48pm UTC](https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962/1 "2022-07-12T14:48:29Z")

</div>

Hello there, i’ve added a smart field to display the number of bookings my user have in database.

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

// This file allows you to add to your Forest UI:
// - Smart actions: https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions
// - Smart fields: https://docs.forestadmin.com/documentation/reference-guide/fields/create-and-manage-smart-fields
// - Smart relationships: https://docs.forestadmin.com/documentation/reference-guide/relationships/create-a-smart-relationship
// - Smart segments: https://docs.forestadmin.com/documentation/reference-guide/segments/smart-segments
collection('user', {
  actions: [],
  fields: [{
    field: 'count_bookings',
    type: 'Number',
    reference: 'booking.id',
    defaultValue: 0,
    get: function (user) {
      console.log("user.id",user.firstname);
      // return 0;
      return models.booking
        .findAll({
          include: [{
            model: models.user,
            where: { id: user.id }
          }]
        })
        .then((bookings) => {
          console.log("bookings",bookings.length);
          return bookings.length;
        });
    }
  }],
  segments: [],
});

```

console.log show that there is data returned

```javascript
user.id Truong
user.id David
bookings 1
bookings 0

```

but nothing is shown on the dashboard  
 ![Capture d’écran 2022-07-12 à 16.45.17](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/f/f26c7b271bff731e6318134e02817721aa2f3582.png)

Package.json  
“dependencies”: {  
“body-parser”: “^1.20.0”,  
“chalk”: “^1.1.3”,  
“cookie-parser”: “^1.4.4”,  
“cors”: “^2.8.5”,  
“debug”: “^4.0.1”,  
“dotenv”: “^6.1.0”,  
“express”: “^4.17.1”,  
“express-jwt”: “^6.0.0”,  
“forest-express-sequelize”: “^8.5.10”,  
“morgan”: “^1.9.1”,  
“pg”: “^8.2.2”,  
“require-all”: “^3.0.0”,  
“sequelize”: “~5.15.1”,  
“stripe”: “^9.0.0”  
}

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [July 13, 2022, 7:38am UTC](https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962/3 "2022-07-13T07:38:06Z")

</div>

Hey @Jules_Truong 👋

Could you:

- Provide your project name, so I can check on my end if I can spot something
- If possible, provide both the request payload & response body of the `/user` call (Visible in your network tabs in your browser developer console)
- Validate that your smart field in indeed visible in your `.forestadmin-schema.json`?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Jules\_Truong](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jules_truong/32/4430_2.png) [@Jules\_Truong](https://community.forestadmin.com/u/Jules_Truong)\
**Post date:** [July 13, 2022, 8:24am UTC](https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962/4 "2022-07-13T08:24:52Z")

</div>

> [@anon39848301](#):
>
> your sm

projectname : `rayon`  
request payload:

```javascript
timezone=Europe%2FParis&fields%5Baddress%5D=id&fields%5Bcount_bookings%5D=id&fields%5Buser%5D=id%2Cfirstname%2Caddress%2CauthId%2Ccount_bookings%2Cemail%2Cphonenumber%2Clastname%2Croles%2Cstatus%2CstripeRef%2CemailHash%2CemailIsValidated%2CcreatedAt%2CupdatedAt&page%5Bnumber%5D=1&page%5Bsize%5D=15&sort=-id

```

response payload:

```javascript
"relationships":{
            "count_bookings":{
               "data":null,
               "links":{
                  "related":{
                     "href":"/forest/user/2/relationships/count_bookings"
                  }
               }
            },

```

`.forestadmin-schema.json` contains the smart field

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [July 13, 2022, 8:28am UTC](https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962/5 "2022-07-13T08:28:32Z")

</div>

I’m guessing this is not the full response payload, right?  
Eventually, could you try removing the `reference: booking.id` in the smart field definition?

In your case, the response is not particulary related to this reference collection, as you fetch the `models.booking` in the implementation.

---

<div class="post-metadata">

**Author:** ![Jules\_Truong](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jules_truong/32/4430_2.png) [@Jules\_Truong](https://community.forestadmin.com/u/Jules_Truong)\
**Post date:** [July 13, 2022, 8:33am UTC](https://community.forestadmin.com/t/smart-field-does-no-appear-in-dev/4962/6 "2022-07-13T08:33:02Z")

</div>

ok it works ! thank you
