3 add_description_to_all_scrips();
5 sub add_description_to_all_scrips {
7 my $scrips = RT::Scrips->new( RT->SystemUser );
8 $scrips->Limit( FIELD => 'Description', OPERATOR => 'IS', VALUE => 'NULL' );
9 $scrips->Limit( FIELD => 'Description', VALUE => '' );
10 while ( my $scrip = $scrips->Next ) {
11 my $desc = $scrip->Description;
12 next if defined $desc && length $desc;
14 $desc = gen_scrip_description( $scrip );
16 my ($status, $msg) = $scrip->SetDescription( $desc );
18 print STDERR "Couldn't set description of a scrip: $msg";
20 print "Added description to scrip #". $scrip->id ."\n";
25 sub gen_scrip_description {
30 $condition = $scrip->ConditionObj->Name
31 || $scrip->ConditionObj->Description
32 || ('On Condition #'. $scrip->Condition);
37 print STDERR "Reference to missing scrip condition found. If you have ScripCondition = 0 in the Scrips table, update with a real condition number.\n";
38 $condition = 'On undefined Condition # 0';
41 my $action = $scrip->ActionObj->Name
42 || $scrip->ActionObj->Description
43 || ('Run Action #'. $scrip->Action);
44 return join ' ', $condition, $action;