Contact Us

May 28, 2024

June 17, 2026 10:12 pm

Passing Record Id to Employee Agent in Agentforce

Share with

Understanding the Current Record Id Variable

The currentRecordId variable is a pre-defined custom variable in Agent Script that stores the Salesforce ID of the current record. To use this variable, you need to declare it in your Agent Script with the correct visibility parameter.

Agent Script

currentRecordId: mutable id
  description: "The Salesforce ID of the current record"
  visibility: "External"

By declaring the currentRecordId variable with the correct visibility parameter, you can access the record ID of the object the Employee Agent is launched from.

Using the Current Record Id Variable in Agent Script

To use the currentRecordId variable in your Agent Script, you can simply reference it in your script. For example, you can use it to fetch data from the current record or to perform actions on the record.

By using the currentRecordId variable, you can create more dynamic and personalized interactions with your users.

The root cause of the issue is the incorrect declaration of the currentRecordId variable in Agent Script. By adding the visibility parameter, you can access the record ID of the object the Employee Agent is launched from.

Best Practices for Using the Current Record Id Variable

Here are some best practices for using the currentRecordId variable in Agent Script:

Checklist

  • Declare the currentRecordId variable with the correct visibility parameter.
  • Use the currentRecordId variable to fetch data from the current record or to perform actions on the record.
  • Make sure to handle errors and exceptions when using the currentRecordId variable.
  • Test your Agent Script thoroughly to ensure that the currentRecordId variable is working as expected.
  • Use the currentRecordId variable in conjunction with other variables and functions to create more dynamic and personalized interactions with your users.

By following these best practices, you can use the currentRecordId variable effectively in your Agent Script and create more engaging and personalized experiences for your users.

Frequently Asked Questions

What is the currentRecordId variable?

The currentRecordId variable is a pre-defined custom variable in Agent Script that stores the Salesforce ID of the current record.

How do I declare the currentRecordId variable in Agent Script?

You can declare the currentRecordId variable by adding the visibility parameter to the variable declaration.

What are some best practices for using the currentRecordId variable?

Some best practices for using the currentRecordId variable include declaring the variable with the correct visibility parameter, using the variable to fetch data from the current record or to perform actions on the record, and handling errors and exceptions when using the variable.

Can I use the currentRecordId variable in conjunction with other variables and functions?

Yes, you can use the currentRecordId variable in conjunction with other variables and functions to create more dynamic and personalized interactions with your users.

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