Triggering client script on multiple records

I’m exploring options to initiate a client-script on multiple records within a “record list” block. Ideally, users should be able to select various records and execute the script for all chosen records through a single button click.

Here’s my current setup:

  1. Using .on("compose:record"):
  • Outcome: The script works flawlessly on individual record pages.
  • Issue: The script doesn’t appear in the “automation” tab of the “record list”.
  1. Using .on("ui:compose:page-record"):
  • Outcome: The script is visible in both the “record list” automation tab and the individual record page.
  • Issue: The script doesn’t trigger upon clicking the button.

I scoured the documentation to discern the differences between "compose:record" and "ui:compose:page-record", but couldn’t pinpoint clear explanations.

Could anyone provide insight into these distinctions and recommend an approach to achieve the desired functionality? Your guidance would be invaluable.

I suggest you try using workflows to achieve that

Thanks for your reply @jfortun
Indeed I achieve that with workflows for different tasks.
For this task I need to use the browser.sendMessage API, so I have to use a client-script

Does anyone has a solution/suggestion to this? Is it even possible?

You can also try this Resources and events :: Corteza Docs

You’ll see that there is a selected argument for that event

A side note here, if you plan on using the script on a record page, you need to use the compose:record event, otherwise you need to use the compose:page

Thanks for your response. I am familiar with the documentation page you referenced.

As mentioned on my initial post, I had tried both compose:record and ui:compose:record-page.
The compose:record works well, but the script only appears on record page and not on a record-list automation section - so I cannot trigger it on multiple records.
The ui:compose:record-page does appear on both record page and record-list automation section - but it doesn’t work (doesn’t respond when triggered manually by a button click).

Try using this trigger, it should show up.

triggers ({ on }) {
    return on('manual')
      .uiProp('app', 'compose')

Try accessing the selected parameter from the context
async exec ({ selected }, { }) {

Thanks for your respond - I do appreciate it.
Trying your solution, the script doesn’t appear on the record list automation section.
It does appear on the edit record page automation, but it is not triggered upon a button click (as oppose to “compose:record”, where it does work on individual record)
Do you have any other suggestion?

Can you double check the trigger? You wrote .on("ui:compose:page-record") in the initial post
But its called .on("ui:compose:record-page")
Maybe try .on("ui:compose") aswell.

Thank’s a lot @jfortun, I appreciate the time you take to help.
I tried again both your suggestions.
Using “ui:compose:record-page” the script doesn’t show up neither in single record nor in the record list.
Using “ui:compse”, the script appears both on single record page, and in record-list, but it still doesn’t trigger.
On the browser console i see that the corteza-js Dispatch function is throwing a warning: “explicit events require onManual event type”.
if I break on that line in the console, I see that the ev object does not have eventType property. If I break in the same line with “compose:record”, the ev.eventType is defined properly as onManual (and works fine, but only on single record).

Im guessing its a bug, i’ll try to take a look
Otherwise, In the meantime, you could trigger the script via workflow.
That means a workflow trigger that executes the desired script


Also i tried this script works for me, the args parameter successfully contains recordID’s of selected records. Both on record and non record pages.

export default {
  label: 'Script Label',
  description: 'Script Description',

  triggers ({ on }) {
    return on('manual')
      .uiProp('app', 'compose')

  exec (args, ctx) {
    // Code goes here

Thank you very much @jfortun .
I confirm this is working with your settings.