[rt-users] Scrip help needed

Ruslan Zakirov ruslan.zakirov at gmail.com
Thu Sep 24 09:23:28 EDT 2009


Torsten,

Scrips work under system user, but you have to reload ticket as
creator of the transaction. Something like:
...
my $reply_will_be_on = RT::Ticket->new( $txn->CreatorObj );
$reply_will_be_on->Load( $ticket_you_found_as_system_user->id );
$reply_will_be_on->Comment(...);
...

On Thu, Sep 24, 2009 at 2:39 PM, Brumm, Torsten / Kuehne + Nagel / Ham
MI-ID <torsten.brumm at kuehne-nagel.com> wrote:
> Hi Roy,
> no success, still:       RT_System - Comments added
>
> :-(
>
> Thanks
>
> Torsten
>
>
> Kuehne + Nagel (AG & Co.) KG, Geschaeftsleitung: Hans-Georg Brinkmann (Vors.), Dirk Blesius (Stellv.), Reiner Heiken (Stellv.), Bruno Mang, Alfred Manke, Christian Marnetté (Stellv.), Mark Reinhardt (Stellv.), Jens Wollesen, Rainer Wunn, Sitz: Bremen, Registergericht: Bremen, HRA 21928, USt-IdNr.: DE 812773878, Persoenlich haftende Gesellschaft: Kuehne & Nagel A.G., Sitz: Contern/Luxemburg Geschaeftsfuehrender Verwaltungsrat: Klaus-Michael Kuehne
>
>
>
> -----Urspruengliche Nachricht-----
> Von: Raed El-Hames [mailto:rfh at vialtus.com]
> Gesendet: Donnerstag, 24. September 2009 11:59
> An: Brumm, Torsten / Kuehne + Nagel / Ham MI-ID
> Cc: rt-users at lists.bestpractical.com
> Betreff: Re: [rt-users] Scrip help needed
>
> Hi Torsten;
>
> Try
>
> $related->BaseObj->Comment(
>    Creator => $self->TransactionObj->Creator,
>    Content => $self->loc( "Information added by [_1].", # loc
>       $self->TransactionObj->CreatorObj->Name,
>       ) . "\n" . $self->loc( "Notes: [_1]", # loc
>       $note
>       ),
>     );
>
>
> Note the Creator line I added.
>
> Regards;
> Roy
>
> Brumm, Torsten / Kuehne + Nagel / Ham MI-ID wrote:
>> Hi,
>> i'm trying to write a scrip which does the following:
>>
>> We have two or more tickets, each ticket has a refersto to another
>> like this:
>>
>> #1 -> refers to #2
>>
>> Now, if someone at ticket #2 writes an update, this update (reply in
>> our case) should be posted also to ticket #1
>>
>> Till this point it is working fine, now my problem:
>>
>> The Update on Ticket #1 is done by RT_System (from the scrip) after
>> the user in ticket #2 writes an update and i have no idea at the
>> moment, how can i do the update as the user, doing the reply on ticket
>> #2 ?!?
>>
>> The Part of the source writing back the update:
>>
>> $related->BaseObj->Comment(
>>     Content => $self->loc( "Information added by [_1].", # loc
>>        $self->TransactionObj->CreatorObj->Name,
>>        ) . "\n" . $self->loc( "Notes: [_1]", # loc
>>        $note
>>        ),
>>      );
>> I'm not sure how can i add the actual actor from Ticket #2 inside this
>> part of code?!?
>>
>> Below is my full source till now:
>>
>> my $Clone = $self->TicketObj;
>> my $note;
>> my $t = $self->TicketObj->Transactions;  $t->Limit( FIELD => 'Type',
>> VALUE => 'Correspond' );  $t->OrderByCols (
>>   { FIELD => 'Created',  ORDER => 'DESC' },
>>   { FIELD => 'id',     ORDER => 'DESC' },
>>         );
>> my $CommentObj = $t->First;
>> if( $CommentObj && $CommentObj->id ) {  $note = $CommentObj->Content;
>> }; # Get the actual Actor of this transaction my $Actor =
>> $self->TransactionObj->Creator; # $Actor has the ID of the actual
>> Transaction my $temp_user = RT::User->new(); $temp_user->Load($Actor);
>> my $AName = $temp_user->Name(); # Name of Actor in acutal Transaction
>> - possibly not needed
>>
>> while (my $related = $Clone->ReferredToBy->Next) {
>>   my $original = $Clone->id;
>>   my $relid = $related->BaseObj->id;
>>   $related->BaseObj->Comment(
>>     Content => $self->loc( "Information added by [_1].", # loc
>>        $self->TransactionObj->CreatorObj->Name,
>>        ) . "\n" . $self->loc( "Notes: [_1]", # loc
>>        $note
>>        ),
>>      );
>> }
>> return 1;
>>
>> Any help is appriciated.
>>
>> Torsten
>>
>> Kuehne + Nagel (AG & Co.) KG, Geschaeftsleitung: Hans-Georg Brinkmann
>> (Vors.), Dirk Blesius (Stellv.), Reiner Heiken (Stellv.), Bruno Mang,
>> Alfred Manke, Christian Marnetté (Stellv.), Mark Reinhardt (Stellv.),
>> Jens Wollesen, Rainer Wunn, Sitz: Bremen, Registergericht: Bremen, HRA
>> 21928, USt-IdNr.: DE 812773878, Persoenlich haftende Gesellschaft:
>> Kuehne & Nagel A.G., Sitz: Contern/Luxemburg, Geschaeftsfuehrender
>> Verwaltungsrat: Klaus-Michael Kuehne
>>
>>
>
> _______________________________________________
> 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
>



-- 
Best regards, Ruslan.



More information about the rt-users mailing list