Handle click on custom resourece action button
Hello. I've created new action with `actionType: 'resource' but I want to intercept the click before go to the page with component. For example I need to collect all the query parameters before open new custom action page. Please, advise how can I do it?
P.S. before and after hooks are not triggered for resource action.
In general how can I add click handler for custom action? For example I don't want to open new page by click but perform API call
If you share your code it would be a little easier to help you, but something like this should work.
CustomAction: {
actionType: "resource",
icon: "Renew",
component: false,
handler: async (req, res, context) => {
//Do whatever you want
return {
notice: { message: "Done" },
}
},
}
Thank you @AshotN for the response. It works but seems handler function is triggered only when component: false.
Let me explain what is my goal.
I want to download some CSV file based on the query parameters when click on action button
I understand that downloading can be started only from component. So it's vicious circle, on the one hand downloading can be started from component, on the other hand - handler function can't be triggered when component is set.
It's obviously that query parameter must be passed somehow to component and use them to make API call and return attachment to browser.
Please, advise how can I solve this issue
Why before, after and handler functions isn't triggered for new action with actionType: 'resource', when component is set? How it can be fixed?

Any new update about this one ?