Redirecting to another collection as a result of Smart Action

Is there a way to redirect to collection (by name, for example) within Smart Action handler?

Because right now the only way I found in docs is to provide url containing several segments, like so:

// Internal redirection
router.post('/actions/show-some-activity', permissionMiddlewareCreator.smartAction(),
  (req, res) => {
    res.send({
      success: 'Navigated to the activity view.',
      redirectTo: '/MyProject/MyEnvironment/MyTeam/data/20/index/record/20/108/activity',
    });
  }
);

In this approach I understand how to get the MyTeam segment - from user defined on incoming request.
Where should I get values for MyProject and MyEnvironment on the back-end?

Hi @Vasilii,

The /MyProject/MyEnvironment/MyTeam matches with your collection url (in the case of an internal redirection), and should be the URL part just after app.forestadmin.com/.

  • MyProject is your project name, this should not evolve or change a lot in a while, which could potentially be hardcoded IMO.
  • MyEnvironment is agent dependent. My best solution would be to create an environment variable associated to the name you’ve set in your forestadmin UI.
  • MyTeam could be read from the JWT token (More info here)

Let me know if that helps :pray:

1 Like

Hi, @jeffladiray
Thanks for clarifications!