Getting started with custom objects

Have more questions? Submit a request

12 Comments

  • Matt Claycomb
    Comment actions Permalink

    Hello,

    In this article, it is specified that a many-to-many relationship is possible, however I am not finding how. If I attempt to submit a request to the API to create a relation which I believe would handle that (source and target are arrays), I get returned an error saying "Cannot create a relationship type where both source and target are arrays".

    Also, is there a feature request page for having Custom Resources loaded into Insights? That function could greatly benefit our company as well.

    Thank you,

    0
  • Jason Martens
    Comment actions Permalink

    Hello Matt, to represent many-to-many relationships, you need to create multiple relationship types that go in both directions. Let me know if that doesn't work for you for some reason.

    I'm not sure about the Insights question yet, someone will follow up about that.  

    0
  • Matt Claycomb
    Comment actions Permalink

    Jason,

    I am not sure I follow. I know in an SQL database, I would have to use an intermediary table. Take the following example, if I want a many-to-many relationship between the Zendesk type ticket and a custom object named "location", I would have to do the following:

    1. Create the custom object type "location".
    2. Create a custom object type "location_ticket".
    3. Create a many-to-one relationship type from "location" to "location_ticket" named "location-has-many-location_ticket".
    4. Create a one-to-many relationship type from "location_ticket" to "location" named "location_ticket-belongs-to-location".
    5. Create a many-to-one relationship type from "zen:ticket" to "location_ticket" named "zen:ticket-has-many-location_ticket".
    6. Create a one-to-many relationship type from "location_ticket" to "zen:ticket" named "location_ticket-belongs-to-zen:ticket"

    Then any time I want to associate a ticket to a location or an additional location, I would need to do the following:

    1. Create an object of type "location_ticket".
    2. Create a relationship of type "location-has-many-location_ticket" between the "location" and the "location_ticket".
    3. Create a relationship of type "location_ticket-belongs-to-location" the other direction between the "location" and the "location_ticket".
    4. Create a relationship of type "zen:ticket-has-many-location_ticket" between the ticket and the "location_ticket".
    5. Create a relationship of type "location_ticket-belongs-to-zen:ticket" the other direction between the ticket and the "location_ticket".

    Can you let me know if I'm on the right track, or completely off base?

    Thanks,

    Matt

    0
  • Jason Martens
    Comment actions Permalink

    Hi Matt, I think you are on the right track, but I'm not sure you need the `location_ticket` object, unless it's holding additional properties about the relationship. You should be able to create a one-to-many relationship between location -> zen:ticket as well as a one-to-many relationship between zen:ticket -> location. Then when you need to associate a ticket to a location, you would create a ticket -> location relationship for the ticket, and a corresponding location -> ticket relationship if you want to know all tickets associated with a location. 

    0
  • Jason Littrell
    Comment actions Permalink

    Under Associating related objects it states:

    "A relationship record is governed by a relationship type you created. So far you created a one-to-many type named "pc_has_many_tickets" where each ticket can be associated with only one PC, but each PC can be associated with many tickets."

    I'm not seeing this behavior in my tests. The API will let me create multiple relationship records using different PC source IDs with the same "zen:ticket" target. The same applies if I define a one-to-one relationship type. It seems that the single or many schema only affects the number of targets a source can be linked to, but not vice versa. Is this true, or am I doing something wrong?

    0
  • Jason Martens
    Comment actions Permalink

    Hi Jason, when you create multiple relationships with different PC source IDs, you are creating *different* relationships for each PC. The same is true for one-to-one: each relationship is a separate relationship. The difference between one-to-one and one-to-many is that the target field in the one-to-many relationship type is an array. Whereas the target field in the one-to-one is a single ID. 

    You should not be able to create multiple relationships with the *same* PC source ID in either the one-to-one or the one-to-many example. 

    Does that help?

    0
  • Matthew Nataloni
    Comment actions Permalink

    Hello,

    How can I add a drop down to a ticket form and populate it with custom objects that are related to the requester. I created a ticket field and associated the custom objects to the employee, just have been struggling on how to populate the custom objects into the drop down.

    Is this possible?

    0
  • Andrew Schreiner
    Comment actions Permalink

    Hi Matthew,

    I think you could achieve this using an app. I don't believe there is anything baked in that you could use. 

    More info on the ticket apps can be found here. 

    https://developer.zendesk.com/apps/docs/support-api/ticket_sidebar

     

    You would basically want activate on the app.activated function to retrieve your list for the user and then populate the app with the data from the custom object that you want.

    1
  • Matt Owens
    Comment actions Permalink

    Anyone have an example application that is pulling related Objects on a user?

    url: '/api/sunshine/objects/records/zen:user:' + id + '/related/object_record_name',

     

    0
  • Christopher Cooper
    Comment actions Permalink

    Hi Matt,

    Do you have a question about using our List Related Object Records API? You'll want to use the relationship type in the url to return related records. For example, my test account has a user_has_many_devices relationship type. The url I used to get a user's device objects was the following:

    https://z3nt.zendesk.com/api/sunshine/objects/records/zen:user:1274575738/related/user_has_many_devices

    Best,
    Chris

    -1
  • Adam Grohs
    Comment actions Permalink

    Is there any way to access sunshine custom object data from within a ticket body - either via macro or preferably a placeholder?

    1
  • Andrew Schreiner
    Comment actions Permalink

    Adam Grohs, I don't think that's possible. You could write a custom app to insert text into the body of the editor but that would be the only way I know of to get it in there at this time. Sounds like a good idea though so you may want to put in a feature request.

    0

Please sign in to leave a comment.

Powered by Zendesk