I'm trying to find the activity_type with the highest value, so I can ++ that value and insert a new activity type. I thought this would be easy.
I cannot sort on the "value" column of the
option_value table because it is a varchar column containing (in this case) numbers. Take the following api call:
civicrm_api3('OptionValue', 'getsingle', [ 'option_group_id' => 'activity_type', 'options' => ['sort' => 'value DESC', 'limit' => 1] ]);
This ought to return the activity type with the highest value. However, it returns "9" because I guess mysql thinks the string "9" > "62" (which is the actual max in my sandbox).
Anyone have a good approach to suggest?