Sending data from Salesforce to Medallia

The Medallia for Salesforce managed package uses automation mechanisms native to Salesforce to push data to Medallia Experience Cloud via APIs. The package comes with out-of-the-box automations available in Flow Builder or Process Builder as templates for outbound data-send automations. Salesforce admins can also create these automations using Apex Triggers.

Note: Salesforce announced the deprecation of Process Builders and are encouraging all clients to use Flows instead of Processes.
Important: To create Invitation records, users must be provisioned the Medallia App User permission set that comes with the managed package. This permission set must be assigned to users who perform actions such as closing Cases or Opportunities as Salesforce takes the user context of these actions when running automations through tools like Flow Builder or Process Builder.

These are the common use cases activated with this integration.

Flow / ProcessDescription
Send Invitation When Case ClosesSends an invitation after a case closes.
Send Invitation When Opportunity Closes Sends an invitation when an opportunity is closed won or lost.
Send Invitation 60 days After Opportunity is WonSends an invitation to contact in an Onboarding Program
Send Update When Case Closes(Available in Flows Only) Sends an update to Medallia after a case closes. Typically used for closing the loop in Salesforce and you want to send that case's status back to Medallia to keep the systems in sync.
Tip: In practice, the default configuration of the templates do not meet custom business practices (such as filter criteria). As such, most administrators "clone" a template and then modify the cloned template. In that case, you can activate the cloned template.
Note: If your organization prefers to use Flow Builder or Apex Trigger to power your Salesforce automations, these automations are supported with the managed package. When creating Flows or Apex Triggers, invoke the Medallia Apex classes using the templates provided in the Flow Builder or the Process Builder.

Send invitation when case closes

This flow reflects the most standard use case of the package and its use of Field Sets to determine the data transmitted to Medallia Experience Cloud in real-time.

To activate this automation:

  1. Navigate to the Flow Builder or Process Builder.

  2. Click into Send Invitation When Case Closes Process template.

  3. Notice the medalliaOutbound_createSurvey string assigned to the fieldSet variable in the Apex action. This fieldSet defines the data that will be sent to Medallia when a Case closes.

  4. (optional) To modify the list of fields sent, go to Object Manager > Case > Field Sets > medalliaOutbound_createSurvey, and add or remove the fields on this field set.

  5. When your changes are complete, activate the flow or process.

    When using Flows, refer to Debug Flow Builder to test your flow before activation.

  6. To test the Flow / Process, close a Case record in Salesforce. Navigate to the Invitations tab and a new Invitation record should be created and in a Received state. If the status is in New, refer to Troubleshooting for Salesforce Administrators.

Send invitation when opportunity closes

This use-case is the only exception where field sets are not used for data transmission to Medallia Experience Cloud. Instead, the package uses a tabular report in Salesforce that joins Opportunity and Contact objects because the data needed to transmit to Medallia typically resides on both objects, and so, cannot be accessed through a field set.

To leverage a report:

  1. Navigate to the Reports object and go to All Folders.

  2. Click the Medallia folder to find the managed package's template report named Opportunities with Contact Roles Example.

    Alternatively, you can clone the report. If you create your own report, it is important to make sure that this report is saved in a Public Folder or the package will not be able to access the report.

  3. Edit the template or cloned report to add all relevant columns from Opportunity, Contact and Account objects you need. The template report already has a few standard fields configured.

  4. By default, the template report filters are set to see All Opportunities across all time.

    Note that both the Opportunity.ID and Contact.ID fields are blank. This is required for the report to work with the package Apex classes.

    A list of filters that include an Opportunity ID filter

You will need the report ID to use the report in the Apex action of a Flow or Process. Find the report ID in the URL. Once you have the report ID, set up and activate the automation to trigger the invitation to be sent to Medallia.

Flow Builder

Follow these steps to activate this automation in Flow Builder.

  1. Clone the Send Invitation When Opportunity Closed Flow template.

  2. Open the Send Invitation Opportunity Lost and/or Send Invitation Opportunity Won Apex actions.

  3. Set the reportID Apex variable to the report ID created above.

    Image showing Edit Apex action options

  4. Activate the Flow. Refer to Debug Flow Builder to test your flow before activation.

To verify the flow:

  1. Identify an Opportunity with a Primary Contact Role associated with it and close the Opportunity record as Closed Won or Lost.

  2. Navigate to the Invitations tab and an Invitation record should be created with a Received status.

    If the status is in New, refer to Troubleshooting for Salesforce Administrators.

Process Builder

Follow these steps to activate this automation in Process Builder.

  1. Clone the Send Invitation When Opportunity Closed process.

  2. Delete the existing Apex action and create a new action that references the medallia_xm__MedProcessSendInvitation class and set the following Apex variables

    • Service — sfdc_create_survey_opportunity_won OR sfdc_create_survey_opportunity_lost

    • whenToSend — now()

    • recordID — Opportunity.Id

    • reportID — report ID created in previous step

    Image showing the four variable as defined in Call Apex

  3. Activate the Process.

To verify the process:

  1. Identify an Opportunity with a Primary Contact Role associated with it and close the Opportunity record as Closed Won or Lost.

  2. Navigate to the Invitations tab and an Invitation record should be created with a Received status. .

    If the status is in New, refer to Troubleshooting for Salesforce Administrators.

By default, the Apex classes that trigger on the Opportunity object send Invitations to the Primary Contact. An Apex variable, SendInviteToRole, can be added to the Process or Flow Action to send invitations that modify this behavior. When using this apex variable, choose Type "String" and enter one of the following in the Value input box:

ValueUse case
PrimaryContactOnlyDefault behavior: Send invitations to only Primary Contact Role
AllContactRolesSend invitations to all Contact Roles on an Opportunity
PrimaryAndSelectedSend invitations to Primary and Selected Contact Roles.*
MedalliaSelectedOnlySend invitations to Contact Roles that have the Medallia Selected field checked.*
Important: When setting Apex variable to PrimaryAndSelected or MedalliaSelectedOnly, add OpportunityContactRole.Add_to_Medallia_Program__c field to the Contact Role page layout. When this field is checked, Medallia Experience Cloud creates and sends an invitation tied to the Contact Role record. If unchecked, Experience Cloud does not send an invitation to this record.

Create an invitation via a feedback program

Salesforce users can manually create and queue Invitations to be sent to Medallia Experience Cloud using the Salesforce UI. This is enabled via a button enabled on Contact list views and layouts called 'Add to Program' as shown in the screenshot below. When Salesforce users click this button, they can assign the Feedback Program and date that Contacts should receive survey invitations. These invitations can be date-based to schedule the survey to be sent at a specified date in the future, instead of immediately.

Showing the Add to Program button opening a scheduler dialog

To enable this functionality, a Salesforce admin creates program records on the Feedback Program object. Each Feedback Program in Salesforce should be associated with an Experience Program in Medallia Experience Cloud. Define each program and work with your Medallia administrator to associate it to an Experience Cloud Program.

To create a program record in Salesforce:

  1. In Salesforce Lightning, click the Feedback Programs tab.

    You may need to add the Feedback Program tab to your menu.

  2. Click New.

  3. Enter the details for the new feedback program:

    • Program Name — name for this program to appear in the Salesforce Programs list.

    • Description — (optional) description or purpose of the program

    • isActive — (optional) Yes shows this program in the menu of available programs on the Add to Program page; No hides it as an available option.

    • Is Date Based Event — allow users to schedule surveys in the future; otherwise, unselected, hides the date scheduler on Add to Program screen.

    • Recurrence Days — for date-based program, set a recurring invitation, such as 90 for 90 days.

    • Program Service — webfeed endpoint (when different from the default). Consult with your Medallia services partner to determine the endpoint.

    • Disable Duplicate Checking — allows a Contact to be invited more than once in a date-based program.

    • Medallia Spec IDThe field is deprecated, but still required. Enter any value in this field.

  4. Click Save.

After the Feedback Program records have been created, follow these steps to add the Add to Program button to the Contact layout in Salesforce Lightning reporting.

  1. Add the Add to Program button to the Contact List view and to the Contact page layout you want to modify:

    1. Navigate to Object Manager > Contact > Search Layouts for Salesforce Classic.

    2. Select the List View layout from the list and click Edit.

    3. Select the Add to Program button.

    4. Click Save.

    5. Navigate to Object Manager > Contact > Page Layouts > Select the [Contact Page layout] to modify > buttons.

    6. Drag the Add to Program button on to the page in the Custom Buttons section and click Add to shuttle it over as a Selected Button.

      'Add to Program' option shown on the Contacts page

    7. Click Save.

  2. Add the Add to Program button to the Accounts Contact Related list:

    1. Navigate to Object Manager > Accounts > Page Layouts > Select the [Account Page layout] to modify > Related Lists > Contacts.

    2. Click Properties, then click Buttons.

    3. Select the Add to Program button.

    4. Click Save.

  3. Add the Remove Invitation button to the Feedback Program, Invitations related list:

    1. Navigate to Object Manager > Feedback Program > Page Layouts > Feedback Program Pagelayout > Related Lists > Invitations.

    2. Click Properties, then click Buttons.

    3. Select Remove Invitations Button.

    4. Click Save.

If your Salesforce org is using the Classic interface, follow these steps to enable the app components:

  1. Set up page layouts — The Add to Program button can be added to the Account (Person accounts only) and Contact page layouts. The normal process for updating a page layout still applies:

    1. Go to the Account and/or Contact page layout you'd like to have the button added to.

    2. Drag Medallia's Add to Program button onto the Custom Button section of the page layout.

    3. Click Save.

      Note: The Add to Program button, when used for Accounts, is supported for Person accounts only. You will get an error if you attempt to add an account that is not a Person Account.
  2. Set up list views — The Add to Program button can be added to the Account (Person accounts only) and/or Contact list views. From Setup:

    1. Go to Customize, and then the Standard object you'd like to update.

    2. Select the Search Layout option, and scroll to the List View section and click Edit.

    3. You will see the "Add to Program" button from the Medallia app; select it to add it as a List View button.

    4. Click Save.

      Note: The Add to Program button, when used for Accounts, is supported for Person accounts only. You will get an error if you attempt to add an account that is not a Person Account.
  3. Set up a contact Related List — In the Account page layout, you can setup the Add to Program button onto the Related List for Contacts.

    1. Edit the Account page layout you'd like to add the button to, and scroll to the related list section.

    2. Find the Contact related list, and click the gear icon at the far right of the Related List.

    3. Once inside the editor, scroll to the buttons section, and you'll see the Add to Program button. Click to add it to the Related List.

    4. Click Save.

To test the functionality as a user, follow these steps. Users can add 200 invitations at a time in the Salesforce Contact list view.

  1. Click the Contacts tab.

  2. Select one or more Contacts to invite to provide feedback.

  3. Click Add to Program from the Action menu.

  4. On the Add to Program page, use Select a program to identify the survey program.

    • (optional if enabled) Select a date in the future to send the survey. Otherwise, the invitations are triggered on the same day.

  5. Click Schedule to save the invitation(s).

If Invitations are scheduled to be sent today, the Invitation Status should be updated to Received. For Invitations scheduled to be sent in the future, follow the directions in Schedule the daily batch job to set up the batch job to push the invitation data to Medallia Experience Cloud on the scheduled date.

Note: Invitations created from the Add to Program functionality leverage a field set on the Contact object labeled as medalliaOutbound_createSurvey, which determines the data payload that Medallia receives. To modify the data Medallia receives, go to Object Manager > Contact > Field Sets > medalliaOutbound_createSurvey, and add/remove the fields on this field set.

Schedule the daily batch job

When Invitations records are created with scheduled send dates in the future (done with the Add to Program functionality), the managed package pushes that invitation data to Medallia Experience Cloud on a daily basis as specified by the scheduling of the MedDailySyncJob Apex class.

The MedDailySync processes Invitation records that meet the following two conditions:

  1. The Invitation record has a status of NEW, and

  2. The Invitation Date_to_Send is in the past.

If those conditions are met, then the Apex job creates a QueueItem record for each invitation and creates an asynchronous operation to pass these records to Medallia via an API.

  1. From Salesforce Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex.

  2. Select the MedDailySyncJob job.

  3. For Job Name, enter MedDailySyncJob.

  4. For Frequency, choose Weekly and choose every day in the list of Recurs every week on.

  5. Specify the start and end dates to run the class. 

  6. For the Preferred Start Time, choose 1:00am.

  7. Click Save.

Important: The Apex job sends records to Medallia Experience Cloud in batches. The default batch size is 10. To change this, modify the Record Size custom setting in the Medallia Settings. Be mindful of the average character length of a record's payload as Salesforce has a 131,700 character limit for outbound API requests.

Schedule Apex class to run every day weekly

Create Invitation from a Custom Object

Medallia Experience Cloud can enable creation of Invitations beyond standard objects like Cases, Opportunities, and Contacts. The managed package is flexible to create invitations from events that occur on custom objects. As noted in Send invitation when case closes, the package relies on a field set to be created on the custom object to determine the data that is pushed to Experience Cloud.

To create an Invitation from an automation triggered from a Custom object, follow these steps. These steps describe how this can be enabled through Process Builder, though this can be extended to Flow Builder or Apex Triggers as well.

  1. Create a new Flow triggered on a creation and/or update to a Custom object.

  2. Create an action that invokes the medallia_xm__MedGenericProcess Apex class.

  3. Set the following Apex variables:

    • service — (Insert value provided by your Medallia admin).

    • whenToSend — now() assuming invitation should be sent immediately. Otherwise, write a formula based on your business requirements.

    • recordID — Custom Object record ID.

    • sendInvite — true

    • fieldSet —The API label for the field set you've created on the custom object. Note: Include the custom object's record ID in the field set; otherwise, the automation will fail to update an Invitation's status.

  4. Activate your Flow Builder.

Test the flow by updating or creating a record that triggers the Flow / Process.

Create Invitations via DataLoader

A Salesforce Data Loader allows Salesforce admins to bulk create records through CSV files. Bulk loading should be done only as a one-time effort when launching your Medallia for Salesforce integration.

To bulk create Invitation records, create a CSV file with the following columns and values as listed below. Insert the records into the Invitation object through Data Loader. Note that this example is relevant for when invitation payloads are based off a Contact field set. Consult with your Medallia representative if your use-case for bulk loading Invitations differs from the example below.

  • Medallia Service = Set to the service as advised by your Medallia contact

  • Account = Account Record ID

  • Contact = Contact Record ID

  • Date to Send

  • Status = New

  • Owner = User ID

  • Field Set = field set label on the Contact object

  • Is Generic = False

When viewed in a worksheet, the data looks similar to this:

A row of data in a worksheet with the column labels matching the list above

Sync close-the-loop data to Medallia

While the main use case of the sending Salesforce data to Medallia Experience Cloud is to send Medallia invitation data, there are additional cases for sending data to Medallia outside of invitations. The most common example of this is when Salesforce tracks customer follow-ups through Cases or Tasks, and you want to send this activity to Experience Cloud for aggregate reporting.

To enable this data sync, leverage the Send Update When Case Closes Flow template. This example assumes that a Case is used to close the loop with a customer, although you can extend this to Tasks or another custom object.

Flow Builder

To use Flow Builder to close the loop:

  1. Click into the Send Update When Case Closes template in Flow Builder.

  2. The default criteria for the action is set to Case Status = Closed and Medallia Feedback ID is not null. Add additional criteria, such as Case Type, depending on the business logic for creating follow-up Cases are created.

  3. Notice the medalliaOutbound_closeAlert string assigned to the fieldSet variable in the Apex action. This fieldSet defines the data that will be sent to Experience Cloud when a follow-up Case closes.

    • Ensure that a unique identifier (such as the Invitation ID or Response ID) is part of this field Set so Experience Cloud knows what record to update on its side.

  4. (optional) To modify the list of fields sent to Experience Cloud, go to Object Manager > Case > Field Sets > medalliaOutbound_closeAlert and add/remove the fields on this field set.

  5. Activate your Flow Builder and test by closing a follow-up Case record.

  6. If successful, your Experience Cloud admin will confirm the payload has been received by Medallia's API. If this does not happen, then refer to the Troubleshooting for Salesforce Administrators.

Process Builder

To use Process Builder to close the loop:

  1. Create a new Process triggered on an update to the Case object.

  2. Set the criteria for the action to be Case Status = Closed. Add additional criteria such as Case Type depending on the business logic for how follow-up Cases are created.

  3. Create an action that invokes the medallia_xm__MedGenericProcess Apex class.

  4. Set the following Apex variables

    • service — (Insert value provided by your Medallia admin).

    • whenToSend — now()

    • recordID — Case ID

    • sendInvite — false

    • fieldSet — The API label for the field set you will set up to determine the data sent to Medallia.

    • Ensure that a unique identifier is part of this field Set such as the Invitation ID or Response ID so that Medallia knows what record to update on its side

  5. Activate your Process Builder and test by closing a follow-up Case record.

If all is successful, your Medallia admin will confirm the payload has been received by Medallia Experience Cloud. If this does not happen, refer to Troubleshooting for Salesforce Administrators.

Debug Flow Builder

Debug flows allows you to troubleshoot an existing flow to better understand the root cause of why an invitation record or case update is not being generated, even after the intended event has occurred. For example, an opportunity or case has been closed but the expected outcome of creating an invitation record has not happened. With debug flows, it is possible to understand if flow actions are running as intended for relevant triggering records.

Similarly, it is also possible to use debug logs to test newly built flows, even if the flow is not yet active. This is a great way to view real-time granular details around what the flow actually produces as an outcome before activating the flow on your Salesforce environment.

To use Flow Builder’s debug tool:

  1. In Flow Builder, Open the flow to debug.

    For example, debug the Send Invitation When Case Closes template.

  2. Click Debug.

  3. Set the debug options and the input variables to run the flow with.

    For the Send Invitation When Case Closes template, un the flow as if the record is updated.

    Debug flow options

  4. Select the triggering record that meets the criteria of being picked up by the flow. This can be a case record that failed to create an invitation as intended, or another record that should generate an invitation once the flow is active.

  5. After selecting the triggering record, set the field values on that specific record being updated.

    For the Send Invitation When Case Closes flow, change the status of the record to Closed given it is the required field update condition that enables the flow to run.

    Debug Flow variables

  6. Click Run.

When the flow runs successfully you see a green Completed tag, as shown below, indicating the record would have triggered as expected. Debug details on the right side detail the outcome of the flow. In the example, notice the MedGenericProcess Send Invitation Apex Class was actioned with the following input variables.

Debug Flow with Completed tag

When the flow fails you see an amber Not Triggered tag indicating the record would not have triggered as expected. As the flow was not staged to run, debug details provide insights as to why the flow did not pick up the run. In the example below, it was because the triggering record did not meet the entry condition requirements.

Debug Flow with Not Triggered tag