1 Reply Latest reply on Nov 12, 2018 2:10 PM by sullivanj

    Time period ticket custom field with API


      I built a frontend for our ticket system that allows the categories to be searched textually as the dropdown system wasn't cutting it for our clients.  There is a custom ticket field of the type Time Period that I can't seem to handle.


      - source code in the assist page for the dropdown refers the the units of time as id 0-5 for mins, hrs, days, weeks, months, years

      - the api returns the duration as a number and the unit as the textual representation

      - the database stores the duration as a float and the unit as a float(appears to be 0.0000-5.0000)


      Could someone point me in the right direction as to what JSON to use to update this field?  I've tried every combination I could think of but have only had success with updated the duration field and not the unit field. 


      Thank in advance,


        • Re: Time period ticket custom field with API

          It's minutes in case someone else runs across this.  The PHP code below will provide a suitable value that can be passed to the api.


          $duration = $value[0];
          if ($value[1] == 0) {
            $amount = $duration;
          } elseif ($value[1] == 1) {
            $amount = $duration * 60;
          } elseif ($value[1] == 2) {
            $amount = $duration * 1440;
          } elseif ($value[1] == 3) {
            $amount = $duration * 10080;
          } elseif ($value[1] == 4) {
            $amount = $duration * 43829;
          } elseif ($value[1] == 5) {
            $amount = $duration * 525948;