Hi -
Is there documentation describing how to generate URLs that deep-link to a page within the Forest Admin interface?
For example, the documentation describes how to redirect to an internal page using a Smart Action. In the example for an internal redirect, this URL is listed:
/MyProject/MyEnvironment/MyTeam/data/20/index/record/20/108/activity
-
Is there a way to retrieve the “MyProject” and “MyEnvironment” values from the request object of the Smart Action so we can dynamically change the redirect URL?
-
What is the structure of the remainder of the URL? I can see that 108
correlates with a record’s primary key, but I can’t seem to figure out what 20
refers to in the example. Could you shed some light?
Thanks!
For #1, I found advice elsewhere in the community that recommends req.user.team
and an environmental variable for MyEnvironment
. MyProject
is pretty static, so no issue hard-coding there. That takes care of question #1!
Looks like I can answer part of question #2: 20
represents a collection_id
that is generated by FA.
Per the documentation, I see in the Smart Action request
object the following field:
request.body.data.attributes.parent_collection_id
but it’s null
when I inspect it. Is this supposed to be null? If not, how can I get the collection_id
from the request
object of a Smart Action?
Thanks again!
p.s. I’m on forest-express-sequelize
version 8.0.0-beta.6
Hi @yeti182,
Your own answers are right
The url pattern is the following:
/MyProject/MyEnvironment/MyTeam/data/{collection_id}/index/record/{collection_id}/{record_id}/activity
To make your smart action work, it misses the collection id.
Collections are now identified by their names. The collection name is present in the smart action request
object. (That allows Forest to make references to collections that are valid across environments, in order to apply layout changes from one environment to another.)
If a collection id is 20
in your project, it means the id does not match the collection name, it’s an old identifier.
We have an issue in this case, sorry for that.
I have to check with the team the possible solutions:
- Migrate your collections ids to reflect the names,
- Put the collection id in the smart action
request
object,
- Allow to define placeholder in URLs,
Hi @Sliman_Medini -
Thanks for your response! Yes, it looks like our collection IDs are still present in URLs in our development environment; however, our staging environment uses collection names. Maybe we just need to clear the schema file?
Thank you for this information,
I am surprised there is a difference for one environment to another, it’s useful to know that.
Can you please share your project name, collection id + name ?
About the idea of dropping forestadmin-schema.json: no sorry it won’t help.
I just PM’d you details. Thanks, @Sliman_Medini!
Please do this only if you are ok with layout changes loss on the environment:
A possible workaround would be to drop/recreate your development environment, with a new env secret (in your .env file).
We will work on a proper solution but it will be released later.
Regards
Thanks, @Sliman_Medini - this is helpful information. We’ll wait for the solution release.
Hi @Sliman_Medini and @yeti182,
We have a similar case where our staging environment always uses “collection names” whereas our production environment sometimes uses “collection id”
Can I do something to always use collection names in the production environment?
@Sliman_Medini I am PMing you my project name, collection id + name
Thanks!
Hi @Yannick_Tian,
Unfortunately, this is a known bug that we have to prioritize but it is not the case yet.
I am adding your case to the ticket in order to give it more weigth.
Please note: The URL always relies on the collection id.
The collection id is 1cf****2f on prod and is jo****er on staging.
As a (dirty, yes) workaround, it’s possible for you to set an environment variable in your server to create URL based on the current environment:
COLLECTION_JO***ER=1cf91**2f //for prod
COLLECTION_JO***ER=jo**er //for staging
And in the code, use process.env.COLLECTION_JO***ER
to specify the collection route segment.
Another solution would be to migrate to development workflow V2. This will merge all collections ids.
Please note that this migration will take the production layout is taken as reference (so collection id will be “1cf***22f”) for all environments. Also, any layout differences in the staging or the dev will be lost. This is explained in the migration process.
Regards
Understood, thanks for your answer!
Good luck with the fix
Best