All records smart action

Desired behavior

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

Hello @Florian_Sureau! :wave: Welcome to our community :tada: :confetti_ball:

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”;'/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

1 Like

Hi @morganperre ,
I still have some problems trying to do that on a reference table in a collection it crashes in the getIdsFromRequest method:
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?


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.