Retrieving Clarity's Related Object Entries
Consuming related data enables complex querying to interact with associated assets and entries. To test querying related object entries, Clarity created two relationships for their Ticket object, including a one-to-many relationship with the Ticket object itself (allowing a ticket to have multiple related tickets).
In this exercise, you’ll query related object data using relationship endpoints and the nestedField
parameter.
Exercise: Querying Clarity’s Related Ticket Data
Here, you’ll retrieve related tickets within the API Explorer.
-
Sign in as the Clarity Admin user.
-
Username:
admin@clarityvisionsolutions.com
-
Password:
learn
-
-
Open the Global Menu (
), go to the Applications tab, and click Tickets. -
Find the first ticket with a
User to Tickets
value of “Renee,” and click on that ticket’s ID.
-
Set the Ticket to Tickets field to the “Test Client Extension Ticket” created in a previous exercise and click Save.
-
Repeat steps 3 and 4 for the second ticket with a User to Tickets of “Renee.”
You should now see two tickets related to the Test Client Extension Ticket:
-
Navigate to the API Explorer at http://localhost:8080/o/api.
-
Click on the REST Applications drop-down and select
c/tickets
. -
Under the Ticket section, expand the
getTicketsPage
endpoint.
-
Set the following parameters and click Execute.
Parameter Value nestedFields ticketToTickets pageSize 40 -
Within the response body, find the
Both tickets should include aticketToTickets
structure within each of the two tickets related to “Test Client Extension Ticket”.r_ticketToTickets_c_ticketId
relationship pointing to the same ID. With the above values, the related ticket ID is 65848. -
Copy the related ticket’s ID.
-
Under the Ticket section, expand the
getTicketTicketToTicketsTicketPage
endpoint. -
Paste the ID into the
ticketId
parameter and click Execute.
-
Examine the returned list to verify that only the two tickets related to “Test Client Extension Ticket” are returned.
Clarity can use similar relationships to retrieve lists of child tickets connected to single parent tickets within their dashboards.
Conclusion
Great! You’ve learned to leverage both the nestedFields
parameter and relationship API endpoints to return related data. This provides an essential baseline to perform complex queries and manage relationships between object entries.
Next, you’ll learn about leveraging search and search suggestions APIs to quickly provide users with relevant results.
Capabilities
Product
Education
Contact Us