Setting a cf_ field in object_end_of_set_all hook

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting a cf_ field in object_end_of_set_all hook

James Walters
I can't seem to get this to work...


I have added a cf_ custom field through the administration interface in
Bugzilla 4.x. When a bug is edited I want to change the value of this
new custom field depending on various new field values in the bug. My
understanding is that my extension needs to hook object_end_of_set_all
hook, which it does. And I can query all the new new bug field values
just fine within the hook. But I cannot get my cf_field to update within
the hook. I have tried using $object->set_cf_myfield() but it can't find
the method. Further, looking at the Voting example (the only example on
the nets I could find) and reading the Bugzilla::Bug source code I
cannot figure out what the parameters of the set_ function(s) should be.
For example, in the voting example the set_ function is:

$object->set_bug_status($new_status,  {  resolution  =>  'MOVED'  });


Why two arguments?

Thanks


_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Setting a cf_ field in object_end_of_set_all hook

Gervase Markham
On 06/09/11 09:21, Jim Walters wrote:
> I have added a cf_ custom field through the administration interface in
> Bugzilla 4.x. When a bug is edited I want to change the value of this
> new custom field depending on various new field values in the bug. My
> understanding is that my extension needs to hook object_end_of_set_all
> hook, which it does. And I can query all the new new bug field values
> just fine within the hook. But I cannot get my cf_field to update within
> the hook.

You set a custom field like this:

my $field = new Bugzilla::Field({ name => 'cf_foobar' });
$bug->set_custom_field($field, 'somevalue');

Gerv

_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Setting a cf_ field in object_end_of_set_all hook

eduuniak
On Friday, September 9, 2011 at 11:19:03 PM UTC+3, Gervase Markham wrote:

> On 06/09/11 09:21, Jim Walters wrote:
> > I have added a cf_ custom field through the administration interface in
> > Bugzilla 4.x. When a bug is edited I want to change the value of this
> > new custom field depending on various new field values in the bug. My
> > understanding is that my extension needs to hook object_end_of_set_all
> > hook, which it does. And I can query all the new new bug field values
> > just fine within the hook. But I cannot get my cf_field to update within
> > the hook.
>
> You set a custom field like this:
>
> my $field = new Bugzilla::Field({ name => 'cf_foobar' });
> $bug->set_custom_field($field, 'somevalue');
>
> Gerv

Hello Gerv,

This is old post. But it seems there only a few discussions about Bugzilla extensions in Internet.

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 $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 ?

Which method can be used to get its value or check if it's not empty ?


Yours sincerely
Alexander Konrad


_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Setting a cf_ field in object_end_of_set_all hook

Gervase Markham
On 07/12/17 11:35, [hidden email] wrote:
> How to check condition if some custom field empty?
> For example, it's possible to check that qa_contact is not set.

What have you tried? Looking at like 4586 (!) of Bug.pm, it seems like
maybe:

if ($bug->custom_field_name eq "") {
    ...
}

would work, and is probably the right way to go. But
$bug->{'custom_field_name'} may well work too.

Gerv
_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.