All Collections
Gearset for data sandbox seeding
Why were dependencies of my records not deployed?
Why were dependencies of my records not deployed?

How to configure a data deployment to include the records you need

Tom Smith avatar
Written by Tom Smith
Updated over a week ago

Deploying data dependencies can be difficult and counter-intuitive. The Gearset data loader detects referenced objects and brings related records into the deployment, but this referencing only works in one direction.

In this article, we'll show a scenario where an object's references weren't deployed, and explain how you can better configure the data deployment.

This example will walk through deploying an Account and its related records.

Here's an account. It has 2 contacts, 4 opportunities and 3 cases.

The configuration that won't work

When we select Account in the Gearset data loader configuration, we might also expect Gearset to deploy the related contacts, opportunities and cases.

Unfortunately, this won't work as we'd expect. Gearset will deploy accounts, but not the contacts, opportunities and cases.

What went wrong?

When Gearset deploys dependencies, it follows lookup fields to find those dependencies.

Salesforce displays accounts in a way that makes it look like Account has lookup fields to Contact, Opportunity and Case.

However, Account doesn't have these lookup fields.

In the Sales Objects model, the lookup fields are on Contact, Opportunity and Case, pointing to Account. There's also a lookup field from OpportunityLineItem to Opportunity.

Here's a simplified version of the Sales Objects model.

Here is the Salesforce Schema builder showing this relationship:

When Gearset checked for lookup fields on Account, there weren't any to follow. All the lookup fields point to Account, rather than from Account. This means that we didn't find the related contacts, opportunities and cases, so didn't deploy them.

The configuration that will work

The data model

We can think of our data model as a tree.

Account is the root because it doesn't point to any of the objects we're interested in. 

Case, Contact and OpportunityLineItem are the leaves because none of the objects we're interested in point to them.

Opportunity is a node because it points to another object, and has another object pointing at it.

Configuring the deployment

To configure the deployment, we need to select all the leaves. Gearset will follow the lookup fields all the way to the root and deploy all of the records we wanted.

We'll select Contact, Case and OpportunityLineItem.

In the next step, we'll see Account and Opportunity as related objects and include them in the deployment.

When we run the deployment, Gearset will deploy:

  • any contacts, cases and opportunity line items up to the record limit

  • any opportunities referenced by any of those opportunity line items

  • any accounts referenced by any of those contacts, opportunities and cases

In this example, we'll assume that our record limit is high enough for all of the contacts, cases and opportunity line items in the org to be deployed.

Why are the opportunities still missing?

In the screenshot above, the account has 2 contacts and 3 cases, but no opportunities.

None of the opportunities on the account had any products attached. This means that they had no opportunity line items.

We only deployed opportunities that were referenced by opportunity line items. Since these opportunities didn't have any opportunity line items, they weren't deployed.

To make sure the opportunities on our account are deployed, we can add Opportunity to our configuration. We need to keep OpportunityLineItem selected in our configuration, otherwise any opportunity line items in the source org won't be deployed.

Now, we'll only include Account as a related object, because Opportunity is already included.

When we run the deployment, Gearset will deploy:

  • any contacts, cases, opportunities and opportunity line items up to the record limit

  • any additional opportunities referenced by any of those opportunity line items

  • any accounts referenced by any of those contacts, opportunities and cases

In this example, we'll assume that our record limit is high enough for all of the contacts, cases, opportunities and opportunity line items in the org to be deployed.

This gives us the account with 2 contacts, 4 opportunities and 3 cases.

Why are some accounts still missing?

In the same way that the opportunities were missing before, we might have some missing accounts.

If an account isn't referenced by any contact, opportunity or case, then it won't be deployed.

To deploy those accounts, we can add Account to our configuration. We need to keep Contact, Case, Opportunity and OpportunityLineItem selected in our configuration, otherwise none of the accounts will have any related records (as we saw in the configuration that didn't work).

Why are some records still missing?

When we select an object in our configuration, each object is subject to the maximum record limit.

For example, in our source org we might have 80 accounts, each of which has 20 contacts, which means we have 1,600 total contacts.

If the record limit for Contact is set to 1,000 then Gearset will only deploy 1,000 contacts. These aren't necessarily from the same account, meaning we may deploy 40 accounts with all 20 contacts and 40 accounts with only 5 contacts.

We can use filters to ensure that we bring in all of the related records for specific accounts.

How can I filter the deployment to records belonging to specific accounts?

Perhaps we're only interested in accounts that were created in 2020, in which case we might not want to deploy contacts, opportunities and cases belonging to other accounts.

We'll select Contact, Case and OpportunityLineItem for deployment again, and include Opportunity and Account as related objects. This will deploy:

  • any contacts, cases and opportunity line items up to the record limit

  • any opportunities referenced by any of those opportunity line items

  • any accounts referenced by any of those contacts, opportunities and cases

We need to make sure that Gearset only deploys accounts created in 2020. This means that we need to filter the contacts, opportunities and cases to records referencing accounts created in 2020.

To filter Contact and Case, we need to add a formula field to each object that points to Account.CreatedDate. You can read more about filtering with formula fields in this article.

To filter opportunities, we need to filter our opportunity line items so that Gearset only deploys opportunity line items referencing opportunities that reference accounts created in 2020.

To filter OpportunityLineItem, we need to add a formula field which points to Opportunity.Account.CreatedDate

In Gearset, we need to add our filter to Contact, Case and OpportunityLineItem, and then include Account and Opportunity as related objects.

To ensure that Gearset deploys opportunities without any opportunity line items, or accounts that aren't referenced by any contacts, opportunities or cases, we'll also need to include Account and Opportunity in our configuration, using the same filters.

With our filters, we ensure that all of our objects are below the maximum record limit. This means that Gearset will deploy all of the accounts that we want, and all of the records related to those accounts.

Did this answer your question?