Solutions keyboard_arrow_down keyboard_arrow_up
Our Solutions
Ontraport's solutions work together to give you everything you need to run your business in one centralized, easy-to-use platform.
Select your industry to see how our CRM and marketing software can support your growth
Learn more
Resources keyboard_arrow_down keyboard_arrow_up
Resources
Find free content on the latest marketing strategies, using Ontraport in your business, and finding the right software.
Visit the blog
Pricing Chat
Try our free interactive customer portal demo!
Want to offer the convenient, self-service experiences your customers are looking for? Check out this free demo to see what you can create in Ontraport without code or developers.
arrow_forward
Get your free demo

Want to offer the convenient, self-service experiences your customers want?

Check out this free customer portal demo to see what you can build in Ontraport without code or developers.

Get your free demo

HomeOntraport for no-code web appsCustom Objects > Relationship management
Home > Custom Objects  >  Relationship management
Relationship management
You’ll learn how to automatically create objects that have relationships to other records and how to change relationship types between objects when needed. With these tricks up your sleeve, you’ll be able to automate things and build web apps with your custom object data.
You'll learn:
  • How the system handles adding, changing or removing relationships by relationship type
  • The tools used to create related records
  • How to use unique fields so that Ontraport will update existing records (rather than create duplicates)
  • How hidden fields help you update related records without collecting contacts’ data again
  • The logic behind intermediate objects for many-to-many relationships
Instructor
Jason Howell
Relationship management
You’ll learn how to automatically create objects that have relationships to other records and how to change relationship types between objects when needed. With these tricks up your sleeve, you’ll be able to automate things and build web apps with your custom object data.
You'll learn:
  • How the system handles adding, changing or removing relationships by relationship type
  • The tools used to create related records
  • How to use unique fields so that Ontraport will update existing records (rather than create duplicates)
  • How hidden fields help you update related records without collecting contacts’ data again
  • The logic behind intermediate objects for many-to-many relationships
Course Instructor
Jason Howell
Related resources
Comments
settings
settings
settings
settings
[Block//Author//First Name] [Block//Author//Last Name] on [Block//Date Added %F j, Y g:i a%+0d0h0m]
[Block//Comment]
Transcript
Storing and accessing data about custom object records is obviously important if you’re running a business. And by now, you’re almost an expert!

But if you want to automate things or build web applications with your custom object data, there are a handful of tricks you’ll want to know. More specifically, you’ll want to know how to automatically create objects that have relationships to other records and how to automatically add, remove or change relationship types between objects when certain things happen.

For example, if someone registers their new pet on your website, you of course want to create a record for that new pet. But you also want to automatically create a relationship between that pet and the contact who filled out the form, so you know whose pet it is.

On the other hand, if someone has to give their dog to a different owner for whatever reason, you want to make it easy for them to let you know that they don’t own that pet anymore. Maybe you want a button they can click that says “Not my dog,” which will automatically remove that relationship.

Or, imagine you’re selling tickets to an event. When someone buys a ticket, you want to automatically create a new ticket record that’s related to both the event and the ticket holder.

There are several ways to create records and change relationships automatically in Ontraport, and how you do it depends on what the relationship type is.

So let’s get into the meat of it. 

There are three relationship types, and basically three tools you can use to add or remove relationships automatically: forms, automations and the API, or application programming interface.

Take a quick peek at this chart. It shows you the tools you can use in each situation to create records, add or change relationships and remove relationships:


Create related recordAdd/Change relationshipRemove relationship
One-to-oneForms, APIForms, Automations, APIForms, Automations, API
One-to-many Forms, APIForms, Automations, APIForms, Automations, API
Many-to-manyAPIAPIAPI

What you’ll notice is that it’s pretty easy to make these changes to one-to-one and one-to-many relationships, but it requires the API to deal with many-to-many relationships. That’s just the nature of that kind of relationship; it’s harder to deal with the data. 

Fortunately — as we talked about in a previous video — you can typically replace many-to-many relationships by using an intermediate object.

So let’s walk through each of the tools, starting with forms because that’s going to be the most common tool you’ll use — and the most important.

A cool thing about Ontraport is that you can create forms for custom objects just like you can for contacts. When you fill out those forms, a custom object record is created instead of a contact. And you can use these forms to update existing custom object records just like you can with contacts.

But you’ll need to give the system some way of knowing which records to update. You’ll do this using unique fields. 

For example, if someone fills out a form with an email address that already exists in another record, the system won’t create a new contact record. It will, however, update the existing contact record with the matching email address. 

With custom objects, there are no email address fields by default, so you’ll need some way of matching up records. This is where unique fields come in. 

 You’ll go to the field editor, create a field and click the checkbox here to indicate that this field should be unique — meaning that only one record in this object can have any particular value in there. So if someone fills out that form field with a value that already exists, Ontraport will update the existing record rather than create a new one.

Now here’s the fancy part. Forms can create more than one record at a time, and they’ll automatically be linked together using the relationship type you choose.

Let me show you what I mean:

Going back to our pet and pet owner example, let’s say you want a way for pet owners to register their new pets on their own.

You’d create a custom object form for “Pets,” which you now know how to do after watching the other videos in this course. Once that form is filled out, a new pet record gets created. 

But the pet record isn’t enough! You need that record to be connected to its owner, so you know what’s what.

All you need to do is add the pet owner’s email address to the form — although really, any unique field from the contact record will work. You’ll simply add a new field and then find the pet owner’s email address.

So let’s start with a blank page for now and add a form field. The system asks which object you want to create with this form, so put “Pet Name.” If you fill this out, you’ll get a new pet record. 

Add another field. This time, you’re going to click on the “Pet Owner” relationship. Then you’ll see all the pet owner’s fields, and you can add as many as you like. For now, just add a name and email address. 

So now you have the pet owner’s name, email address and their pet’s name. If you fill this form out and the pet owner’s email doesn’t already exist in your account, then two records will be created — one for the pet and one for the pet owner. They’ll also be related, so you can see who the pet’s owner is.

Cool, right? But wait, there’s more.

Let’s say you also want to capture information about the pet’s emergency contact. Remember we talked about this in an earlier video. The emergency contact is also a contact, but not the pet’s owner. 

Now, you’re going to add the emergency contact’s name and email. This time, you need to find the emergency contact relationship instead of the pet owner relationship. 

Even though you’re picking the same field both times — the email address from your contacts object — the relationship you pick determines how these records are going to be related to each other.

When you fill this form out, three records get created and they’re all linked up as they should be.

But now let’s add another twist to solve a common problem.

One annoying thing that often happens online is that people have several email addresses, and they won’t always give you the same one when they fill out your forms.

That can get messy because you don’t want two records for the same pet owner. You just want one place where you can see all the pets a person owns.

The best way to avoid that is to simply not ask for the owner’s email if you already have it.

There are a couple ways to deal with that, but the easiest and most foolproof way is to put this form inside a membership site. With a membership site, you definitely know who a person is if they logged in. And when you know who that person is, there’s a lot more you can do.

Going back to your form, delete the pet owner’s name and email here and go to your form settings.

Scroll to the bottom, and you’ll find this section for hidden fields. Now, add the email address back in and for the value, put the email address merge field.

Now, the form looks like it’s just asking for the pet name but it’s really submitting the pet owner’s email address as well. Because you know the email already exists in your account, this pet record is going to get created and automatically connected to the contact record for the owner.

You’ll be using this trick all over the place as you build web apps, so it’s a good one to know.

Now that you understand how to use forms to create and connect records, it’s no trouble at all to remove relationships using forms. Just submit the form with a blank value in the related field and it’ll be disconnected. 

For example, if you wanted to make a button that disconnects a dog from its owner, you could create a form for the pet, put the pet’s unique name on there and then use a hidden field to add the owner’s email but then simply leave the field value blank. When that’s submitted, the dog’s owner field will be blanked out.

And with that, I’ve basically covered what you need to know about using forms to create related records and add or change relationships between records. 

Next up is how to manage relationships using automation. 

Looking back at our chart of features here, you’ll find that you can’t currently create records using automation...or at least not without getting into some code using webhooks and the API.


Create related recordAdd/Change relationshipRemove relationship
One-to-oneForms, Automations, APIForms, Automations, APIForms, Automations, API
One-to-manyForms, Automations, APIForms, Automations, APIForms, Automations, API
Many-to-manyAPIAPIAPI


But you can add, change and remove relationships using automations, and that can sometimes be useful. I will say that there will rarely be times when you’ll need to change a parent record with an automation. Most of the time, you’ll use forms for that. 

But it’s easy enough to do if you need to. Just remember to always build your automation in the child object, then add an ”Update Record” element, select the relationship field and then pick a value. 

And that’s it. Any record that goes through this automation will become the child of the parent record you select.

To remove a relationship, you’d just leave the record blank. Then, any record that runs through here will become an orphan, so to speak.

Finally, I’ll talk a little about managing relationships with the API. I won’t dive into the API here in this course because this course is for non-coders. 

However, if you are a coder and you know how to use an API, we have great documentation for ours at the link below. 

But while you’re here, I’m going to give you one hot, secret tip: there’s actually no such thing as a many-to-many relationship. I know, it’s crazy.

We let you build them in the interface, because people think many-to-many relationships should exist and they want them. But relational databases don’t really work like that, because they’re a pain.

The truth is, whenever you create a many-to-many relationship in the database, an intermediate object gets created for you that is the child of both sides of your many-to-many object. Engineers actually call this a “join table,” but it’s really just another object in Ontraport. 

That object is exposed for you in the API. It’s even got a few fields in there, like “Date added” and “Date modified.” Finding and working with that object is how you’re going to create, update and edit many-to-many relationships using the API.

You’ll find it pretty easily by looking at your list of objects, which you can do using our live API docs at the link below. The object name will be whatever you called the relationship in each of the objects, separated by a slash. The object name will look like this: 

Okay, that should be enough to get you what you need for now. From here, it’s pretty easy to do anything you want to with many-to-many relationships — and any of the other relationship types, really — using the API.

And that wraps up our course on custom objects!

That was a lot of new stuff, and some of it may have felt complicated. But with a little practice, managing your data and getting it all set up right will get easier.

Having all your data set up right is the foundation for what comes next: using your data to create personalized online experiences with Ontraport’s dynamic content management system. Let’s dive into that next.
About Ontraport
Partners & Integrations
Resources
Getting Started

Turn your business on with Ontraport.

[bot_catcher]