How to check condition if some custom field empty?
For example, it's possible to check that qa_contact is not set.
sub object_end_of_set_all {
my ($self, $args) = @_;
my $object = $args->{'object'};
if ($object->{'bug_status'} eq 'RESOLVED') {
if ($object->{'qa_contact'} eq "") {
ThrowUserError("empty_qa_contact");
}
}
}
Is there is same way for custom field e.g. cf_test ?
I know that to save custom field in variable, need to:
my $test = new Bugzilla::Field({ name => 'cf_test' });
Which method can be used to get its value or check if it's not empty ?
Found out two problems: 1. After executing ThrowUserError("...") any object (cf_test or even bugzilla fields) is always NULL. 2. If to use Hook "object_end_of_set_all" for custom field then only a cached values are showed for a custom field.
The answer is to use different Hook:
sub bug_end_of_update {
my ($self, $args) = @_;
my ($bug, $old_bug, $timestamp, $changes) = @$args{qw(bug old_bug timestamp changes)};
if ($bug->bug_status eq 'RESOLVED') {
if ($bug->cf_test eq "") {
ThrowUserError("test_is_empty");
}
}
}