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
targetsproperty to pass custom variables to the renderer - Make sure to set the custom variable in a previous action
- Use the
context.variablesyntax to reference the custom variable - Test the lightning component with the custom variable
- Use the
lightningTypeproperty 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.
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.