How to pass variables to a route?

I am triggering a route from a smart action, and in this case, I am getting the ID of the selected row, and some constant variable:

var value1 = request.body.data.attributes.ids[0];
var value2 = 'secret';

What if I wanted to now redirect the user, to a different collection (a smartview) and pass some information, which isn’t necessarily part of the targets collection, but should be used with rendering the view, or in the ember js controller. Normally I would assume, I could pass these as path or query parameters, e.g.

response.send({
        success         : 'Go to a smartview.',
        redirectTo      : '.../mySmartview/{value1}?bar={value2 }
    });

But I don’t see a way for me, inside the component to read what these values were.
How would I renderer the collection mySmartview, and access these two variables?

Hi @deequestion,

Welcome to the Forest Admin community :evergreen_tree:

Unfortunately you cannot access to a collection and precise the Smart View to display this collection.
The collection will always be displayed with the default view configured.

So right now, the best you can do is to configure your collection with the Smart View you’ve created and redirect to this collection at the end of the Smart Action controller (using redirectTo as you did).
You can, of course, add query params to the URL but I am not sure it will be accessible in your Smart View (I didn’t test it).

Hope it will help.

Hi Arnaud.

Thank you for your response. In this case, it is the ladder part of your answer that we are trying to do.

  1. From some collection, a smart action is available.
    image1

  2. The logic inside this smart actions route, should redirect the user onto another collection, which is a smart view of course. Note this code is an example,

router.post('/actions/view-on-map', (request, response) => {

    const selection  = request.body.data.attributes.ids[0];
    const number    = 1;
    const redirectTo = `.../some_collection?selection=${selection}&number=${number}`
	
	..
	
    response.send({
        success         : 'Went to view on map.',
        redirectTo      : redirectTo
    });
});

Our problem is, creating a smart action, and defining the logic in it, works fine. Redirecting to a collection without attching any query parameters, works fine. But how do we pass some information to the route, e.g. as here trying to passing two things: selection and number, and how do we define the collection route, so that it actually is called and can read the parameters?

Hello @deequestion,

Thanks for your reply. I tested on my end, both to pass parameters as query params, or as a hash and both are not supported right now.

I’m adding your need into our feature requests

Hi Guillaume,

It seem like a normal feature, to be able to pass a query parameter between routes, so I appreciate both you looking into it, and adding it to a feature request.

Thank you.