Per-record but not smart chart?

Hi (again :)),

My name is Bruno, I’m the CTO of Offishall [www.offishall.io]

I’m using the Node agent + express + Postgres. No Sequelize, no Mongoose.
Everything runs smoothly now.

Is it possible to add a per-record chart ? Not a smart chart, let’s say I want to have a distribution chart for active/inactive users within a given company, in the “Analytics” tab.

I didn’t see any relevant information to do so ?

agent.addChart("someChart", async (context, resultBuilder) => {...}

does not seems to expose any recordId, even when I’m calling it from an analytics tab.

Any idea ?

Thanks !

Hello Bruno

Just checked, and you are totally right.

The reason you’re not seeing that method is because we forgot to spec it in this new agent… so it never got implemented.

We released the first beta of the package 6 months ago, and it looks like you are the first to notice :sweat_smile:

I’ll create a high priority bug so that this gets fixed ASAP.

Thanks ! Please keep me in touch :slight_smile:

The easiest way for me would probably be to add a chart directly from the collection object in that case (record specific) and keep the “addChart” method from the agent object the way it is for non record specific charts.

That was our intention as well

I’m done implementing the missing feature.
It should be merged today

Once done, you can update both @forestadmin/agent and the connector you are using to the latest version, and hopefully everything should work

Hi !

Thank you so much for your fast work. I’ve waited for the PR to be merged and I can confirm that it works just as expected. Honestly, this agent improved our workflow so much.

Note: I noticed a very small typic in the documentation, where you wrote agent.customizerCollection instead of agent.customizeCollection

Thank you again!

Bruno

I opened a PR for that

Hi,

I’m trying to add a smart chart for a collection, but I didn’t find how to fetch the recordId within the code ?

I’ve tried to set the fetch method to “POST” , with a json body, but that doesn’t work.

Is it possible ?

Thanks

When you query the URL from the smart chart, either the request body or the query string should have record_id parameter.

Something like this should do the job:

const path = `/forest/_charts/myTableChart?record_id=${this.args.record.id}`
const data = await this.lianaServerFetch.fetch(path, {});`

Documentation on our side is lacking.
I’m adding a ticket to the bug tracker so that this gets better documentation.

That works well. Thanks Romain!