Set Content via Scrip


#1

Hello All,

Im running RT.4.0.5.

I’ve been trying to automatically set the Content(message body) of a comment
on a ticket.

I can get the value from the message input box via
"$self->TransactionObj->Content" but I’m unable to set it via a scrip.

I’ve attempted via “$self->TransactionObj->SetContent($MyValue)” and various
other means (ContentObj | TicketObj | Transaction->Message | …) but none
works…

Here’s a brief explanation on why I’m attempting to do this:

I’ve a couple of Transaction Custom fields, for which I store the input
value in a Ticket CustomField (I do this via a TransactionBatch Scrip), this
works fine on Ticket Creation and as long as the message box contains
whatever value during Comment | Reply | Resolve | Re-Open |… . But if the
message box is left empty, the valued entered in the Transaction CF is not
added to the Ticket CF (perhaps the Scrip is not even run because there’s
Transaction to be recorded?).

How could I either force a TransactionBatch scrip to run even if the message
box is left empty or automatically set a value to Content (the message box).

After taking a look at the RT Logger, it looks like the Scrip is not being
executed if the message box is empty (no Transaction to be recorded perhaps?
even though I’m inputting new values in the Transaction CF(s)).

Nonetheless here’s my Scrip that tries and set a value to Content

Custom condition:
return 1;
Custom action preparation code:
return 1;

Custom action cleanup code:
my $Trans = $self->TransactionObj;

my $content = $Trans->Content;
my $MyValue = ‘ScriptedValue’;

$Trans->SetContent($MyValue);

$RT::Logger->debug("$self->TransactionObj->Content: $content");

Thank you all!
View this message in context: http://old.nabble.com/Set-Content-via-Scrip-tp34014709p34014709.html


#2

Hi,

Transaction CFs are called “transaction CFs” because they need a
transaction to be recorded. Probably the right thing to do is to
return people back to the form if they picked CF values and didn’t
enter any message.

Looks like you use TxnFCs to implement “change ticket CFs on update
(reply/comment)”. If so then wiki has code to make it possible. May be
these days an extension exists to do it.On Fri, Jun 15, 2012 at 1:36 AM, TheHoboKing demon_eyes_kyoms@hotmail.com wrote:

Hello All,

Im running RT.4.0.5.

I’ve been trying to automatically set the Content(message body) of a comment
on a ticket.

I can get the value from the message input box via
"$self->TransactionObj->Content" but I’m unable to set it via a scrip.

I’ve attempted via “$self->TransactionObj->SetContent($MyValue)” and various
other means (ContentObj | TicketObj | Transaction->Message | …) but none
works…

Here’s a brief explanation on why I’m attempting to do this:

I’ve a couple of Transaction Custom fields, for which I store the input
value in a Ticket CustomField (I do this via a TransactionBatch Scrip), this
works fine on Ticket Creation and as long as the message box contains
whatever value during Comment | Reply | Resolve | Re-Open |… . But if the
message box is left empty, the valued entered in the Transaction CF is not
added to the Ticket CF (perhaps the Scrip is not even run because there’s
Transaction to be recorded?).

How could I either force a TransactionBatch scrip to run even if the message
box is left empty or automatically set a value to Content (the message box).

After taking a look at the RT Logger, it looks like the Scrip is not being
executed if the message box is empty (no Transaction to be recorded perhaps?
even though I’m inputting new values in the Transaction CF(s)).

Nonetheless here’s my Scrip that tries and set a value to Content

Custom condition:
return 1;
Custom action preparation code:
return 1;

Custom action cleanup code:
my $Trans = $self->TransactionObj;

my $content = $Trans->Content;
my $MyValue = ‘ScriptedValue’;

$Trans->SetContent($MyValue);

$RT::Logger->debug("$self->TransactionObj->Content: $content");

Thank you all!

View this message in context: http://old.nabble.com/Set-Content-via-Scrip-tp34014709p34014709.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.

Best regards, Ruslan.


#3

Hi,

Just ran into the same problem that you did and, after finding out your
question was still unanswered, got it working.
Although its been a while, if this might still be useful for you, this is
the syntax you were looking for:

$self->TransactionObj->ContentObj->__Set( Field => ‘Content’, Value =>
‘blabla’);

View this message in context: http://requesttracker.8502.n7.nabble.com/Set-Content-via-Scrip-tp43404p55894.html


Edit mail content before Notification