Iβve copied the example in the Generic on click action section of the client automation-scripts docs. Based on the name of the section, it seems to indicate you can press a button to trigger it. But buttons seem to only be able to trigger workflows.
hello-world-client.js content (taken diirectly from the docs except for the console log):
export default {
label: "hello-world-client",
description: "A sample client automation script",
triggers ({ on }) {
return on('manual')
// vv Don't remove the next line vv
.uiProp('app', 'compose')
},
// If you don't need the Compose helper, remove it
async exec ({ $record }, { Compose }) {
// Code goes here
// Note: unless false or an error, the return value is ignored
console.log("Hello")
},
}
I aslo tried looking for something other than a workflow that the button can trigger, but as seen in the image below, only workflow are shown.
The .for(...) tells the webapp what thing the script is for, which then instructs the interface on how to filter the list.
The βwhat thing the script is forβ also dictates what arguments the execution receives.
The .for('compose:record'), for example, makes the script for records β available for record pages.
If you want a generic script, you can use .for('compose').
The example youβve copied β in all honesty, Iβm not sure if it was my mistake, worked on an older version, or was meant to be appended to β but we should have it updated and clarified.
Do note that when youβre developing client scripts, youβll need to refresh your page because client scripts are bundled and served as a bundle to the webapp.
In case the scripts are still not available β restart your containers. When using containerised instances, weβve noticed the file watchers sometimes fail to pick up changes. Here is the Corredor env reference.