[Rt-commit] rt branch, 3.8/basedon-initialdata, created. rt-3.8.9-14-g8092f47

Kevin Falcone falcone at bestpractical.com
Tue Mar 1 11:50:15 EST 2011


The branch, 3.8/basedon-initialdata has been created
        at  8092f47d5d54c24fcd6e078115e878cd65c8a213 (commit)

- Log -----------------------------------------------------------------
commit 8092f47d5d54c24fcd6e078115e878cd65c8a213
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Mar 1 11:38:43 2011 -0500

    Handle BasedOn in initialdata
    
    Now you can specify new-style categories while creating custom fields

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index b9a017c..ff49608 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -845,6 +845,22 @@ sub InsertData {
                 next;
             }
 
+            if ( $item->{'BasedOn'} ) {
+                my $basedon = RT::CustomField->new($RT::SystemUser);
+                my ($ok, $msg ) = $basedon->LoadByCols( Name => $item->{'BasedOn'},
+                                                        LookupType => $new_entry->LookupType );
+                if ($ok) {
+                    ($ok, $msg) = $new_entry->SetBasedOn( $basedon );
+                    if ($ok) {
+                        $RT::Logger->debug("Added BasedOn $item->{BasedOn}: $msg");
+                    } else {
+                        $RT::Logger->error("Failed to add basedOn $item->{BasedOn}: $msg");
+                    }
+                } else {
+                    $RT::Logger->error("Unable to load $item->{BasedOn} as a $item->{LookupType} CF.  Skipping BasedOn");
+                }
+            }
+
             foreach my $value ( @{$values} ) {
                 my ( $return, $msg ) = $new_entry->AddValue(%$value);
                 $RT::Logger->error( $msg ) unless $return;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list