# All records smart action

**URL:** <https://community.forestadmin.com/t/all-records-smart-action/2503>\
**Category:** Help me!\
**Created:** [May 17, 2021, 1:02pm UTC](https://community.forestadmin.com/t/all-records-smart-action/2503 "2021-05-17T13:02:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian\_Sureau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian_sureau/32/2198_2.png) [@Florian\_Sureau](https://community.forestadmin.com/u/Florian_Sureau)\
**Post date:** [May 17, 2021, 1:02pm UTC](https://community.forestadmin.com/t/all-records-smart-action/2503/1 "2021-05-17T13:02:17Z")

</div>

## Desired behavior

Hi,  
I’m trying to execute an action on all records of a segment collection. My smart action exports elements from a collection. When I select records from the current page, it works find (from Ids attribute). But on all records, I’m wondering what is the best way to do it.  
Should I re-create the query based on the current segment, with selected fields? Or is there another way?

(Latest versions)

thank you  
Florian.

---

<div class="post-metadata">

**Author:** ![morganperre](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/morganperre/32/1296_2.png) [@morganperre](https://community.forestadmin.com/u/morganperre)\
**Post date:** [May 17, 2021, 1:09pm UTC](https://community.forestadmin.com/t/all-records-smart-action/2503/2 "2021-05-17T13:09:26Z")

</div>

Hello @Florian_Sureau! 👋 Welcome to our community 🎉 🎊

There is a way. If you are on the `express` liana you can take a look at the following example.

…  
import { RecordsGetter } from “forest-express-sequelize”;

```javascript
router.post('/actions/mark-as-live', permissionMiddlewareCreator.smartAction(), (req, res) => {
  return new RecordsGetter(companies).getIdsFromRequest(req)
    .then((companyIds) => {
      return companies
        .update({ status: 'live' }, { where: { id: companyIds }})
        .then(() => {
          res.send({ success: 'Company is now live!' });
        });
    });
});

```

I hope it will help. Best regards  
Morgan.

---

<div class="post-metadata">

**Author:** ![Florian\_Sureau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian_sureau/32/2198_2.png) [@Florian\_Sureau](https://community.forestadmin.com/u/Florian_Sureau)\
**Post date:** [May 21, 2021, 7:40am UTC](https://community.forestadmin.com/t/all-records-smart-action/2503/3 "2021-05-21T07:40:14Z")

</div>

Hi @morganperre ,  
I still have some problems trying to do that on a reference table in a collection it crashes in the getIdsFromRequest method:  
…/node\_modules/forest-express/dist/services/base-operator-date-parser.js:35  
var offsetClient = Number.parseInt((0, \_momentTimezone[“default”])().tz(options.timezone).format(‘Z’), 10);  
TypeError: Cannot read property ‘format’ of undefined  
at IdsFromRequestRetriever.perform (/Users/fsureau/Dev/kpler-forest/node\_modules/forest-express/dist/services/ids-from-request-retriever.js:135:19)

Ex: I have organisations and users linked to an organisation. When accessing the list of users for a specific organisation, (from organisation collection), and executing the action on the complete list I have this problem.

Any idea?

Regards,  
Florian.

---

<div class="post-metadata">

**Author:** ![morganperre](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/morganperre/32/1296_2.png) [@morganperre](https://community.forestadmin.com/u/morganperre)\
**Post date:** [May 24, 2021, 10:04am UTC](https://community.forestadmin.com/t/all-records-smart-action/2503/4 "2021-05-24T10:04:12Z")

</div>

Hey @Florian_Sureau,

I’m not able to reproduce.  
Can you share your configuration, project name and your `forest-express-sequelize` version ?

Thanks. I’m looking forward to hearing from you.  
Morgan
