Contact Us

April 18, 2024

May 13, 2026 2:13 pm

Rendering lightning component with custom variable in Agentforce

Share with

Understanding the Issue

When using lightning types in Agentforce, it can be challenging to pass custom variables to the renderer. This is because the lightning type has both an editor for input and a renderer for output, and the custom variable is set in a previous action.

Solution

To solve this issue, you can use the targets property in the lightning type to pass the custom variable to the renderer. This allows you to render the editor LWC and use the custom variable at the same time.

Here is an example of how to use the targets property:

agentforce.json

{
  "lightningType": {
    "editor": "myEditor",
    "renderer": "myRenderer",
    "targets": [
      {
        "key": "myCustomVariable",
        "value": "{{context.variable}}"
      }
    ]
  }
}

The root cause of this issue is the limitation of lightning types in Agentforce, which can make it difficult to pass custom variables to the renderer.

Best Practices

To avoid this issue in the future, make sure to use the targets property when passing custom variables to the renderer.

Checklist

  • Use the targets property to pass custom variables to the renderer
  • Make sure to set the custom variable in a previous action
  • Use the context.variable syntax to reference the custom variable
  • Test the lightning component with the custom variable
  • Use the lightningType property to define the editor and renderer

What is the purpose of the targets property?

The targets property is used to pass custom variables to the renderer.

How do I set a custom variable in a previous action?

You can set a custom variable in a previous action using the context.variable syntax.

What is the syntax for referencing a custom variable?

The syntax for referencing a custom variable is {{context.variable}}.

Can I use the targets property with other lightning components?

Yes, you can use the targets property with other lightning components.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need help shipping this in production?

Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.

Get in Touch with Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert