Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion modules/ROOT/pages/code-based-custom-actions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Custom Actions can be embedded through the Visual Embed SDK in the following two

=== Code based custom action for Liveboards

[NOTE]
Code based custom action for Liveboards do not return data for visualizations in their callback. To get data from a Liveboard object and its visualizations use the `POST /api/rest/2.0/metadata/liveboard/data` API endpoint.

The custom action is applied to all Liveboards.

[source,javascript]
Expand Down Expand Up @@ -206,6 +209,8 @@ const customActions = [{
}, ];
----


////
When the answerId parameter is provided, the system displays custom actions only on the visualization(s) that use the specified underlying answerId.

In this example, consider a Liveboard (lb1) with three visualizations: viz1 (based on ans1), viz2 (based on ans2), and viz3 (based on ans3).
Expand All @@ -229,6 +234,8 @@ const customActions = [{
}, ];

----
////


When `modelIds` is passed in the `dataModelIds`, then the custom action is show for all visualization which are using the columns of the specified model.

Expand Down Expand Up @@ -432,6 +439,9 @@ In this example, for a user who is part of org1 and grp1,

* The custom action will also be shown in any Liveboard where these answers have been pinned.

[NOTE]
`modelColumnNames` are not currently supported for code based custom action for Spotter.

[source,javascript]
----
const customActions = [{
Expand All @@ -445,4 +455,21 @@ const customActions = [{
groupId: ['grp1'],
orgId: ['org1']
}, ];
----
----


=== Add callback to a code based custom action

To add an event handler to listen to the callback event and trigger a data payload as a response when a user clicks on the code based custom action, use the Visual Embed SDK's .on method with EmbedEvent.CustomAction.

[source,javascript]
----
embed.on(EmbedEvent.CustomAction, (payload) => {
if (payload.data.id === 'your-custom-action-id') {
// Your callback logic
console.log("Custom Action event:", payload.data);
}
});
----

Ensure you have created the custom action and noted its id. In your callback, verify the action id in the payload.