1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

SQL Query for Tickets and Custom Fields

Discussion in 'Developing, APIs and extending' started by MohammadQassim, Aug 14, 2016.

  1. MohammadQassim

    MohammadQassim New Member

    Hi,

    I am a mobile developer trying to make an app for my organization. I used the REST API and it is perfect so far.

    However, we have used custom fields in our Kayako. I want to fetch tickets based on custom fields. We have various fields. My target field is made for Mobile number.

    I have full access to the database of our Kayako. But I am not able to figure out how swtickets, swcustomfields and swcustomfieldvalues are related to each other.

    My custom field is: 9tyhlnlg9jst

    So, please I want a SQL query that list all tickets and their custom fields where `9tyhlnlg9jst`='MobileNumberHere'
     
  2. chesheng

    chesheng New Member

    I am encouraging you to create a new REST API to support querying tickets from a CustomField value.
    Or you may simply use the SQL statement like this:

    SELECT * FROM swtickets
    INNER JOIN swcustomfieldvalues ON swtickets.ticketid=typeid
    INNER JOIN swcustomfields ON swcustomfieldvalues.customfieldid=swcustomfields.customfieldid
    WHERE swcustomfields.fieldname='9tyhlnlg9jst' AND swcustomfieldvalues.fieldvalue='MobileNumberHere';
     

Share This Page