Developer Bytes | Custom Objects with Zack Wolfson | Part 2: Modifying a Custom Object

Brian and Zack Wolfson show how to modify custom object schemas using PATCH calls to set display properties and add new fields. They cover immutable flags like "has unique values," associating schemas with additional object types, and how CRUD operations for custom objects work the same way as for contacts and companies.
Chapters
Hey folks, welcome to part two of a three part series covering custom objects with Zach Wolfson. In the first part, we discuss what objects are and how to create your own custom object. In this episode, Zach is going to show me how to modify custom object schema. As always, if you have questions or comments, let us know. Okay, enough of me. Let's get back to Zach.
So now let's take a look at what it looks like over here. All right, so now from Brian, now we can see here. So here's where our primary display property comes in. Now that's not particularly useful. Okay, the T1, but someone like Brian might own multiple cars. Maybe multiple the same model, you know, maybe the car collector like Jay Leno. So we can do here now is, let's take a look over at the next tab I have here. What I'm going to do is I'm going to run a patch call. Now you'll notice I have the object type ID here as a parameter, so I'm going to fill that in with the object type ID that came back from our create call and that will insert itself into the URL. What I'm going to do is I'm going to use this to now define some secondary display properties which were missing from my initial call. We don't have that in here. That's okay, they're not required. You see, the result came back as an empty array. Now go here and hit send. Great. Oh, error. I can't have it as both the secondary and primary, which makes sense. So let's remove that here. There we go. Now we've created it and now we have secondary primary display properties. So let's refresh this and see what that looks like. There we go.
Oh yeah.
Oh yeah.
It's much more useful.
Yeah, so it automatically brings in like kind of the label of the property and the values here. So that's a nice thing you might want to do. And you can change that anytime after the fact. Doesn't matter. As long as you have those properties defined in the properties section.
Okay, cool. So, so in that patch, just out of curiosity, can I change the required properties?
Is that, is that possible or is
that once you set it you have
to keep it, you can change the required properties. The one thing that will happen is you have to make sure that kind of the things you've already created, in this case the cars have a value for it. Otherwise you'll have trouble kind of saving those. But otherwise you can change things after the fact. The one thing you can't Change after the fact is a has unique values property. So that's the vin. In this case, it has to be true from the start. It can't start as false and then move to true. You can move it from true to false, but value in doing that.
Right,
and then the other thing that you can do here with schemas is associate them to more objects. So the other thing I wanted to show here is before we only allowed you to associate a car with a person. Well, what if we also wanted to add that to a company as well? Now we could have done that on the schema create time, but maybe we either our business model changed, we didn't lease out to companies, and now we do, or we just forgot. Happens sometimes. So I got to take that from object, object type id. I'm going to put it also in the param section. Use it the URL as well. The body defines it and I give that association a name. In this case, keep it simple, card to company.
So that can be whatever you want to be, right?
The name. The name, yes. Okay, exactly. So now we can see. We created that here. It's back id and let's go back to this car. So now I can add a company. Okay, how about we create a company? Well, anyway, you can see how you get added here.
Yep, yep, makes sense.
Cool.
And so once again, on the whole patch, let's say I have new custom properties that I want to add to this this object cars. Is that something that I would do during that patch or do I do
it a different method? Actually do it a different method. So in this case, if you wanted to add a new property, you would use the CRM properties API because after all, this is just a property. So we'll do CRM3 properties and then we'll add our object ID in here. Let's get that copied over. And then we choose JSON body. Great. And so now we can put kind of a new property here.
Okay, yeah, that makes sense.
I don't remember the exact format mistakes, but now that it's a CRM object, you can use the CRM objects API as well to interact with individual cars, not just kind of the metadata about the cars as well. So it all kind of plays nicely together. All of the API calls you're used to making for contacts, companies, you make the same thing for cars. Now just change out that object type ID from contact or company to that 2 dash number we were looking at. Very straightforward.
Well, that sums up this episode the next.
And the final part will be on deleting the custom object.
See you there.










