default value for custom fields of linked ticket

Hi,

Thanks to Best Practical for RT & RTIR, it’s awesome !

I struggle with the following issue :
I have a ticket in RTIR queue “Incident Report”, with all kinds of custom fields… When I create a new incident from this report with the “+” linked button, the default value of the html form are well populated with the value of the first ticket, except fields that are of the following type : image, images, file and files.

What I try to achieve is to have custom field default value for custom field of type “file” to be the value of the linked ticket.

I understand the code for creating defaults value is located in : rt5/local/plugins/RT-IR/html/RTIR/Elements/EditCustomFields lines 65 to 75.

 if ( $link_cf ) {
# XXX: if CF can have only one value then we should use only first value
                $CFDefaults->{"CustomField-".$CustomField->Id} = join "\n",
                    grep defined && length, map $_->Content,
                    @{ $DefaultsFrom->CustomFieldValues( $link_cf->id )->ItemsArrayRef };
                next;
            }

I have trouble to understand this code for debuging.

Going from inside out, the ItemsArrayRef is a DBIx::SearchBuilder method that returns a reference to an array of search results, these coming from the $DefauttsFrom->CustomFieldValues method for the given $link_cf id value. The map $_->Content is getting all the Content fields from these results and, if they’re defined and have a non-zero length, turning them into an array. The join then concatenates all the found array values with a new line (the "\n"). This is then assigned to the $CFDefaults hash, with a key given by the word CustomField- appended with this particular custom field ID.

Hope that helps in your debugging.