1. 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 or to your Kayako. You can visit the forums for the new Kayako here.

Accessing Custom Fields

Discussion in 'Developing, APIs and extending' started by nanabite, Sep 21, 2012.

  1. nanabite

    nanabite Member

    Hi All,

    I am working on a simple app that will interface with our accounting system's API to provide customers with their account balances, overdue invoices, etc.

    To link the two systems together I have created a custom field on the User Organization in Kayako called "Card ID". This links to the unique ID in the other system.

    I would now like to access this "Card ID" field in my controller. I don't know how to get to it though. It doesn't seem to be accessible via the SWIFT_UserOrganization class and the CustomFieldRendererClient seems to be tied in with templates (which I am not using). What I really need is to be able to extract this single field in the controller so that I can pass it into the API call.

    Any assistance would be appreciated.

    Adam
     
  2. nanabite

    nanabite Member

    Hi All,

    Worked out a solution that does the trick so I thought I'd post it here. For now by directly calling the database:

    PHP:
            $this->Database->Query("SELECT * FROM " TABLE_PREFIX "customfieldvalues WHERE customfieldid IN (14) AND typeid = '" $_SWIFT->User->GetProperty('userorganizationid') . "'");
            while (
    $this->Database->NextRecord())
            {
                
    $_fieldValue $this->Database->Record['fieldvalue'];
            }
    The "14" is the custom field ID and is hard coded for now, but ideally this would be stored in the settings for the application.
     

Share This Page