---
schema_version: "1"
id: 968e3de2aaedde71fe92c182089e2e8096d22fdd4340e3a5e5de5b047f4bbbc8
title: Considerations for the Get Engagements Invocable Action
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/engagement_get_engagements_invocable_action_considerations.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.engagement_get_engagements_invocable_action_considerations.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 981bb12c69d5c54c72c0cd4c4963ebf2cc6d6f21b276fe873ac63452b0fb588b
description: Review the considerations when you use the Get Engagements invocable action.
products:
  - Industry Solutions
  - Cross Cloud
release: "264"
---
# Considerations for the Get Engagements Invocable Action

Review the considerations when you use the Get Engagements invocable action.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Starter</strong>, <strong>Professional</strong>, <strong>Enterprise</strong>, and <strong>Unlimited</strong> Editions with the Industry Service Excellence add-on license</td></tr></tbody></table>

The Engagement Interaction, Messaging Session, and Voice Call objects can relate to the Account base object through the default lookup field or a custom lookup field.

Default Lookup Fields  
| Object | Default Lookup Field |
| --- | --- |
| Engagement Interaction | InitiatingAttendee |
| Messaging Session | EndUserAccount |
| Voice Call with the Match Callers to End User Records preference turned on in Amazon Setup | EndUser.Account |
| Voice Call with the Match Callers to End User Records preference turned off in Amazon Setup | ConversationParticipant.ParticipantEntity |

If the objects are related through a custom lookup field, create an invocable action that contains the details of the custom lookup field.

- Apex Invocable Action
    
    ```
    public class GetPreviousEngagements {
    	@InvocableMethod(label='Get Previous Engagements' description='Get Previous Engagements related to Account')
        public static List<GetPreviousEngagementsOutput> getPreviousEngagements(List<GetPreviousEngagementsInput> inputs) {
            if (inputs == null || inputs.isEmpty()) {
                // Please provide valid inputs. Throw custom exceptions
                return null;
            }
            
            String accountId = inputs[0].accountId;
            Integer engagementsCount = inputs[0].engagementsCount;
            
            // Repeat for other engagement types as well such as 'Messaging Session' and 'Voice Call'
            List<EngagementInteraction> engagementInteractions = [Select Id, CreatedDate From EngagementInteraction Where CustomLookupToAccount__c = :accountId 
                                                                  ORDER BY CreatedDate DESC LIMIT :engagementsCount];
    
            List<DataRetrieval.Engagement> engagementList = new List<DataRetrieval.Engagement>();
            for (EngagementInteraction ei: engagementInteractions) {
                DataRetrieval.Engagement engagement = new DataRetrieval.Engagement();
                engagement.recordId = (String) ei.get('Id');
                engagement.objectApiName = 'EngagementInteraction';
                engagementList.add(engagement);
            }
            
            GetPreviousEngagementsOutput output = new GetPreviousEngagementsOutput();
            output.engagements = new DataRetrieval.Engagements(engagementList);
            return new List<GetPreviousEngagementsOutput>{output};
        }
    }
    ```
- Invocable Action Input
    
    ```
    public class GetPreviousEngagementsInput {
        @InvocableVariable(label='Account ID' required=true)
        public String accountId;
            
        @InvocableVariable(label='Engagements Count')
        public Integer engagementsCount;
    }
    ```
- Invocable Action Output
    
    ```
    public class GetPreviousEngagementsOutput {
    	@InvocableVariable(label='Engagements')
        public DataRetrieval.Engagements engagements;
    }
    ```

After you create the invocable action:

- Replace the getEngagements invocable action with the new invocable action in the Service Innovations Einstein Copilot: Get Engagements Details flow.
- Create a fault path to the AddEmptyPromptInstructionsNoAccount element in the Service Innovations Einstein Copilot: Get Engagements Details flow.
- In the Advanced section of the invocable action properties, select the **Manually assign variables** checkbox and store the output values in the variable used in the getEngagements invocable action.