[rt-users] Default value
Kenneth Crocker
KFCrocker at lbl.gov
Mon Sep 24 13:06:53 EDT 2007
Mathew,
I think I know why. In your scrip code, you define your $CFObj using
current user See line below).
my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
I update our global field for ALL E_mail creates with the ticket
subject line (this is so I ALWAYS get some sort of description in my
Global CF "Description. I use the following code:
# set description
my $cf_obj;
my $cf_name;
my $cf_value;
$cf_obj = RT::CustomField->new($RT::SystemUser);
$cf_name = "Description";
$cf_value = $self->TicketObj->Subject();
$RT::Logger->debug( $self . " cf_value = ". $cf_value . "\n" );
$cf_obj->LoadByName( Name => $cf_name );
$RT::Logger->debug( "Loaded \$cf_obj->Name = ". $cf_obj->Name() ."\n" );
$cf_obj->AddValueForObject( Object=>$self->TicketObj, Content=>$cf_value, );
In my code, I don't use "CurrentUser", I use "$RT::SystemUser". I also
do not define it as a QueueObj. That might make a difference. Try it and
let me know. Hope this helps.
Kenn
LBNL
On 9/24/2007 9:40 AM, Mathew Snyder wrote:
> What is even stranger is that when looking at the custom fields for each queue,
> this particular CF shows up as global. However, I wasn't able to modify it via
> my scrip until I did explicitly apply it.
>
> Keep up with me and what I'm up to: http://theillien.blogspot.com
>
>
> Kenneth Crocker wrote:
>> Mathew,
>>
>>
>> That does seem strange. I have only about 25 custom fields and only
>> one is global. It is not applied to ANY queue and the groups rights are
>> set so everyone can see it but only privileged can modify it. All others
>> are applied on a queue-by-queue basis with the group rights set as
>> needed for a queue. I don't understand why you needed to apply this
>> global CF to ANY queue.
>>
>>
>> Kenn
>> LBNL
>>
>> On 9/24/2007 8:26 AM, Mathew Snyder wrote:
>>> Figured it out. Seems that despite a CF being created as a Global, it
>>> has to be
>>> explicitly applied to a queue...strange.
>>>
>>> Keep up with me and what I'm up to: http://theillien.blogspot.com
>>>
>>>
>>> Mathew Snyder wrote:
>>>> I have one DV that I set to a default value whenever a ticket is
>>>> created. I've
>>>> tried to port this over to another queue with a different CF/value
>>>> but it
>>>> doesn't seem to work. Here's the code:
>>>>
>>>> my $CFName = 'Environment';
>>>> my $DefaultValue = 'default_value';
>>>> my $RecTransaction = 1;
>>>> my $QueueObj = $self->TicketObj->QueueObj;
>>>> my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
>>>>
>>>> $CFObj->LoadByNameAndQueue( Name => $CFName, Queue => $QueueObj->id );
>>>>
>>>> unless( $CFObj->id ) {
>>>> $CFObj->LoadByNameAndQueue( Name => $CFName, Queue => 7 );
>>>> unless( $CFObj->id ) {
>>>> $RT::Logger->warning("custom field '$CFName' isn't global or
>>>> defined for
>>>> queue '". $QueueObj->Name ."'");
>>>> return undef;
>>>> }
>>>> }
>>>>
>>>> unless( $self->TicketObj->FirstCustomFieldValue( $CFObj->id ) ) {
>>>> my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue(
>>>> Field => $CFObj->id,
>>>> Value => $DefaultValue,
>>>> RecordTransaction => $RecTransaction );
>>>> unless( $st ) {
>>>> $RT::Logger->warning( "Couldn't set $DefaultValue as value for CF
>>>> $CFName:".
>>>> $msg );
>>>> return undef;
>>>> }
>>>> }
>>>> return 1;
>>>>
>>>> The only thing I've changed between the two queues is the name of the
>>>> CF, the
>>>> value of the CF and the queue number as it is stored in the DB.
>>>> Anyone have any
>>>> thoughts as to why this isn't working?
>>>>
>>> _______________________________________________
>>> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>>>
>>> Community help: http://wiki.bestpractical.com
>>> Commercial support: sales at bestpractical.com
>>>
>>>
>>> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>>> Buy a copy at http://rtbook.bestpractical.com
>>>
>>>
>
More information about the rt-users
mailing list