RT v5.0.0 - RT::CustomFieldValues::External help with Categories

I’ve got the basic functionality working and populated with external data, but I can’t make head nor tail of the sparse description of how to implement categories. Does anyone have a working example or tips on how to make categories work?

Either I’m doing something wrong or it doesn’t work the way I think it does or there is a bug?

I’'m pulling in a list of sites which are both customer and core network. I want to make the “Select one value Autocomplete” only select based on the category value of “Customer” or “Core”. These values are selected in a separate Custom Field called SiteTypes.

I’ve created the SiteTypes custom field and populated it with static entries “Customer” and “Core”. The documentation seems to imply that the “Sites” category field should return the name of the “SiteTypes” custom field, but I don’t see how this can filter the site names, since all would then have the same category.

I would have thought that the sites category data should be “Customer” or “Core” and then the “depends on category” for the sites custom field should point to sitetypes field, but doing this doesn’t seem to prevent customer sites being returned when the sitetypes custom field is set to Core.

I don’t know if you can do external values and categories together without some digging into code. Normally with categories you see the child and parent value. Like this example of state and city

Correction it looks like you should be able to use external custom field values, just select the corresponding parent value on the child CF ( Where NY is selected above )

What do I return in the category field from my external database? The documentation appears to suggest that I return the name of the 2nd custom field that contains the categories, but this makes no sense.

Doing as the documentation appears to suggest then only associates the selected category with the name in the first field and does nothing to actually filter.

The example of NYC city names and NY category doesn’t seem to be valid, I don’t have the option to select the categories in the static custom field. If I fiddle with settings, the best I seem to get is a list of my site names that can be added as categories to site types, but that seems to be the wrong way round.

I think I probably need to implement RT::Extension::ConditionalCustomFields to get the functionality I’m looking for.

Documentation around categories in RT::CustomFieldValues::External could do with significant improvement including an example that actually demonstrates how it’s supposed to work.

I get how it should work with static fields, but it simply doesn’t seem to work at all with External data.

Going with the city state example:

sub ExternalValues {
    return [
        { name => 'NYC', category => 'NY' },
        { name => 'Boston', category => 'MA' }
    ]
}

I have the above, then in the web UI for cities I select my external values source as my " Field values source: " input and select " Categories are based on " as “States”