Question about API and custom field

Hello There

I come to you with a question on “how to” to do something on RT with a
script.

I did a script to add a customField and It’s working (with one Queue
attached):

my $cf = RT::CustomField->new($RT::SystemUser);
my ($cf_exist, $cf_res_mesg) = $cf->LoadByName(Name=>'Step to

reproduce’);

if (!$cf_exist)
{
    $cf->Create(Name        => $cf_name,
                *Queue       => 'Support',*
                Type        => 'FreeformMultiple',
                Disabled    => 0,
                Pattern     => '(?#Mandatory).',
                LookupType  => 'Ticket',
                Description => 'To define the step to reproduce the

issue’,
Values => [ ]);
}

My question is about the Queue. In fact I need to attache this custom field
to 3 others Queues. I’ve tried to find a solution to do that (with
AddToObject) but I don’t know how to do that. Do you have an idea ?

I don’t ask a full example of course :slight_smile: Just a short help on which function
I need to use with an exemple :slight_smile:

Thank you veru much for your help
http://www.bestpractical.com/docs/rt/4.2/RT/CustomField.html#AddToObject-OBJECT
Kind regards / Cordialement

Alexandre Leprevost
Project Engineer / Delivery Team

4 rue de l´Abreuvoir
92 400 Courbevoie
France
al@efficientip.com
Tel : +33 (0)1 75 84 88 98
Fax : +33 (0)9 57 88 09 40

I found how to do it

For guys wondering how I did it, look the following example :
sub create_step_to_reproduce_cf
{
my $cf_name = ‘Step ro reproduce’;

my $cf = RT::CustomField->new($RT::SystemUser);
my ($cf_exist, $cf_res_mesg) = $cf->LoadByName(Name=>$cf_name);

if (!$cf_exist)
{
    $cf->Create(Name        => $cf_name,
                Queue       => $_[0],
                Type        => 'FreeformMultiple',
                Disabled    => 0,
                Pattern     => '(?#Mandatory).',
                LookupType  => 'Ticket',
                Description => 'To define the step to reproduce the

issue’,
Values => [ ]);

    print "Custom field '".$cf->Name()."' creee\n";

    foreach my $queue_name (@_)
    {
        my $queue = RT::Queue->new($RT::SystemUser);
        $queue->Load($queue_name);

        my $ocf = RT::ObjectCustomField->new($RT::SystemUser);
        $ocf->Create(ObjectId => $queue->Id, CustomField =>$cf->id);
    }
}
else
{
    print "Custom field '".$cf->Name()."' existe deja\n";
}

}

create_step_to_reproduce_cf(‘Support’,‘Presales’,‘Delivery’,‘R&D’);

Kind regards / Cordialement

Alexandre Leprevost
Project Engineer / Delivery Team

4 rue de l´Abreuvoir
92 400 Courbevoie
France
al@efficientip.com
Tel : +33 (0)1 75 84 88 98
Fax : +33 (0)9 57 88 09 40
www.efficientip.com2013/11/8 Alexandre LEPREVOST al@efficientip.com

Hello There

I come to you with a question on “how to” to do something on RT with a
script.

I did a script to add a customField and It’s working (with one Queue
attached):

my $cf = RT::CustomField->new($RT::SystemUser);
my ($cf_exist, $cf_res_mesg) = $cf->LoadByName(Name=>'Step to

reproduce’);

if (!$cf_exist)
{
    $cf->Create(Name        => $cf_name,
                *Queue       => 'Support',*
                Type        => 'FreeformMultiple',
                Disabled    => 0,
                Pattern     => '(?#Mandatory).',
                LookupType  => 'Ticket',
                Description => 'To define the step to reproduce the

issue’,
Values => [ ]);
}

My question is about the Queue. In fact I need to attache this custom
field to 3 others Queues. I’ve tried to find a solution to do that (with
AddToObject) but I don’t know how to do that. Do you have an idea ?

I don’t ask a full example of course :slight_smile: Just a short help on which
function I need to use with an exemple :slight_smile:

Thank you veru much for your help

http://www.bestpractical.com/docs/rt/4.2/RT/CustomField.html#AddToObject-OBJECT
Kind regards / Cordialement

Alexandre Leprevost
Project Engineer / Delivery Team

4 rue de l´Abreuvoir
92 400 Courbevoie
France
al@efficientip.com
Tel : +33 (0)1 75 84 88 98
Fax : +33 (0)9 57 88 09 40
www.efficientip.com