+ # set up custom field, if necessary
+ if ( ! $CustomField->Id ) {
+ # should be RenderType 'Checkbox', but there isn't one yet...
+ my ($val, $msg) = $CustomField->Create(
+ Name => $CUSTOMFIELD_NAME,
+ Type => 'Select',
+ MaxValues => 1,
+ LookupType => 'RT::Queue-RT::Ticket',
+ Description => 'Start subtasks for this ticket',
+ RenderType => 'Dropdown',
+ );
+ if ($val) {
+ # should be impossible for this to fail
+ ($val, $msg) = $CustomField->AddValue(Name => 'Yes');
+ }
+ if (!$val) {
+ push @results, loc("Could not create ticket custom field: [_1]", $msg);
+ } else {
+ push @results, loc("Custom field created");
+ }
+ }
+
+ # apply CF to the queue, iff there are any tasks set up
+ if ( length($new_content) and ! $CustomField->IsAdded($Queue) ) {
+ my ($val, $msg) = $CustomField->AddToObject($QueueObj);
+ if (!$val) {
+ push @results, loc("Could not apply custom field to this queue: [_1]", $msg);
+ } else {
+ push @results, loc("Applied custom field to this queue");
+ }
+ } elsif ( ! length($new_content) and $CustomField->IsAdded($Queue) ) {
+ my ($val, $msg) = $CustomField->RemoveFromObject($QueueObj);
+ if (!$val) {
+ push @results, loc("Could not remove custom field from this queue: [_1]", $msg);
+ } else {
+ push @results, loc("Removed custom field from this queue");
+ }
+ }
+