Loading
Set Up and Maintain Retail Execution
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Set Up Context Passing for Agentforce

          Set Up Context Passing for Agentforce

          Help your agents work faster and with greater accuracy by analyzing contextual data in the Consumer Goods Cloud mobile app. You can define how the app builds and sends this context by setting up process and business logic contracts in your customization project.

          Required Editions

          Available in: Enterprise and Unlimited Editions that have Consumer Goods Cloud enabled
          User Permissions Needed
          To configure context passing for Agentforce Developer, Customizer
          Note
          Note Context passing works when you use Agentforce in the Consumer Goods Cloud mobile app on a physical mobile device. It doesn't work in the Modeler simulator app.

          For example, to pass the visit ID from the store cockpit, perform these steps:

          1. Open your customization project in Visual Studio Code based Modeler.
          2. If needed, define an Action logic in a process contract.
            1. Open the relevant process contract.
            2. Implement a logic to pass data to Action or fetch data from an already available object. In this example, create a logic Action that uses the object name and record ID as input parameters to call the custom business logic.
              <Action actionType="LOGIC" name="LaunchAgentforce" call="ProcessContext::CardController.launchAgentforce">
                 <Parameters>
                      <Input name="objectName" type="Literal" value="Visit" />
                      <Input name="recordId" type="Binding" value="ProcessContext::mainBO.PKey" />
                 </Parameters>
              </Action>
            3. Add the agentforceLaunchEvent external event and bind it to the action.
              <ExternalEvent name="agentforceLaunchEvent" action="LaunchAgentforce" />

            Here’s a sample of the process contract configuration:

            <!-- Define the Action to call the Business Logic function -->
            <Action actionType="LOGIC" name="LaunchAgentforce" call="ProcessContext::CardController.launchAgentforce">
               <Parameters>
                  <!-- Pass the Object API Name -->
                  <Input name="objectName" type="Literal" value="Visit" />
                  <!-- Pass the Record ID dynamically from the current Business Object -->
                  <Input name="recordId" type="Binding" value="ProcessContext::mainBO.PKey" />
               </Parameters>
            </Action>
                  
            <!-- Define the External Event to intercept the header button click -->
            <ExternalEvent name="agentforceLaunchEvent" action="LaunchAgentforce" />
          3. Implement the logic to construct the payload and call the native facade.
            1. Open the business logic contract referenced in your process action.
            2. Implement the function matching the name defined in your Action call.
            3. Construct the JSON payload containing the objectApiName and attributes.
            4. Invoke the Facade.launchAgentForce() function.

            Here’s a sample of the business logic implementation:

            function launchAgentforce(objectName, recordId){
                  var me = this;
            
            //////////////////////////////////////////////////////////////////////////////               
            //                 Add your customizing javaScript code below.              //  
            //////////////////////////////////////////////////////////////////////////////
                  var promise;
            
                  let payload = {
                    "objectAPIName": objectName,
                    "attributes": {
                    "recordId": recordId
                }
            };
            
            Facade.launchAgentForce(payload);
            promise = Promise.resolve();
            
            //////////////////////////////////////////////////////////////////////////////               
            //                 Add your customizing javaScript code above.              //
            ////////////////////////////////////////////////////////////////////////////// 
                  return promise;
             }

          Sample payload structure for a specific visit record that is marked as urgent.

          {
              "objectApiName": "Visit",
              "attributes": {
                "recordId": "a00xx0000012345AAA",
                "pageType": "standard_recordPage",
                "actionName": "view"
              },
              "additionalAttributes": [
                {
                  "name": "customStatus",
                  "value": "urgent",
                  "type": "String"
                }
              ]
          }

          Parameter Details:

          • objectApiName: (String) Required. The API name of the Salesforce object context.
          • attributes: (Object) Required. A container for record identifiers, specifically recordId.
          • additionalAttributes: (Array) Optional. Key-value pairs for extra context.
           
          Loading
          Salesforce Help | Article