my $link_value_to;

my ($major, $minor, $sub) = split(/\./, $RT::VERSION);
if ( $minor < 4 ){
    # For pre RT 4.4
    $link_value_to = '__WebPath__/Search/Results.html?Query=CF.{Tag} = \'__CustomField__\' AND (Status=\'new\' OR Status = \'open\')';
}
else{
    # RT 4.4 introduced __Active__
    $link_value_to = '__WebPath__/Search/Results.html?Query=CF.{Tag} = \'__CustomField__\' AND (Status=\'__Active__\')';
}

@CustomFields = (
    {
        Name        => 'Tag',
        Type        => 'AutocompleteMultiple',
        LookupType  => 'RT::Queue-RT::Ticket',
        Disabled    => 0,
        Description => 'Tags for tickets',
        LinkValueTo => $link_value_to,
        MaxValues   => '0',
    },
);

@ScripConditions = (
    {
      Name                 => 'On Custom Field Change',                                # loc
      Description          => 'When a custom field is changed',                 # loc
      ApplicableTransTypes => 'Create,CustomField',
      ExecModule           => 'CustomFieldChanged',
    },
);

@ScripActions = (

    {
       Name        => 'Add New CF Value',
       Description => 'Add new values to the list of available values for this custom field' ,
       ExecModule => 'AddNewCFValue',
       Argument   => 'Tag'
    },
);

@Scrips = (
    {
       Description    => 'On Custom Field Change Add New Tag Values',
       ScripCondition => 'On Custom Field Change',
       ScripAction    => 'Add New CF Value',
       Template       => 'Blank'
    },
);

