Scrips: User Defined actions and Templates

Hi All,

I want a scrip to use both a User Defined action and a template. My
understanding is that selecting User Defined for the action means that the
template won’t get run. It would be nice to run my “prep” code to modify a
ticket, launch the template, then run my “cleanup” code. Is there a
command that I can put into my custom action that will launch either an
arbitrary template or the one that is in the Template field?

Thanks,
Gene

Gene LeDuc, GSEC
Security Analyst
San Diego State University

At Friday 3/23/2007 07:34 PM, Gene LeDuc wrote:

Hi All,

I want a scrip to use both a User Defined action and a template. My
understanding is that selecting User Defined for the action means
that the template won’t get run. It would be nice to run my “prep”
code to modify a ticket, launch the template, then run my “cleanup”
code. Is there a command that I can put into my custom action that
will launch either an arbitrary template or the one that is in the
Template field?

Thanks,
Gene

Hello Gene,

You can define a custom (user defined) action and still have it use a
template. But the template will just define the content of the email
message sent by the action, and so will only come into play if the
action results in an email message. There’s no way in which a
template can be ‘launched’.

Steve

Hi Stephen,

How do I get the user-defined action to result in an e-mail so that the
template is used? The reason I used “launch” in my original post (when
referring to my templates) is that I’ve had to embed a bunch of code that
modifies the ticket into my templates in order to get both an e-mail and
changes to the ticket in a single step. So they are really programs (in an
e-mail wrapper) that get launched when the condition is true. I’d prefer
to put the code in the scrip and let the template just handle formatting
the mail, but I don’t know how to get the custom action to generate an
e-mail using the template. Is there a command like
“RT::SendEmailUsingScripTemplate”?

What I’ve done is probably confusing, but it’s like this:

  1. Mail comes in to queue 1. A scrip extracts some data and populates some
    custom fields, sets the priority, and moves the ticket to queue 2.
  2. Ticket enters queue 2. Scrip fires and uses Notify Others action to
    “launch” a template.
  3. Template modifies some fields in the ticket and creates e-mail to action
    address.
  4. Action address does their job and replies to mail with “ok”. Scrip in
    queue 2 triggers, modifies some fields in the ticket, moves ticket back to
    queue 1.
  5. Lather, rinse, repeat a couple more times.

What I want to do is take the code that modifies the ticket out of the
template at step 3 and put it into the scrip at step 2, but I don’t know
how to get the scrip to use the template after making the changes to the
ticket. I thought that putting the code in the prep code and returning a
“1” would do it, but nothing happens with the template.

At 06:28 AM 3/26/2007, Stephen Turner wrote:

At Friday 3/23/2007 07:34 PM, Gene LeDuc wrote:

Hi All,

I want a scrip to use both a User Defined action and a template. My
understanding is that selecting User Defined for the action means that
the template won’t get run. It would be nice to run my “prep” code to
modify a ticket, launch the template, then run my “cleanup” code. Is
there a command that I can put into my custom action that will launch
either an arbitrary template or the one that is in the Template field?

Thanks,
Gene

Hello Gene,

You can define a custom (user defined) action and still have it use a
template. But the template will just define the content of the email
message sent by the action, and so will only come into play if the action
results in an email message. There’s no way in which a template can be
‘launched’.

Steve

Gene LeDuc, GSEC
Security Analyst
San Diego State University

At Monday 3/26/2007 12:20 PM, Gene LeDuc wrote:

Hi Stephen,

How do I get the user-defined action to result in an e-mail so that
the template is used? The reason I used “launch” in my original
post (when referring to my templates) is that I’ve had to embed a
bunch of code that modifies the ticket into my templates in order to
get both an e-mail and changes to the ticket in a single step. So
they are really programs (in an e-mail wrapper) that get launched
when the condition is true. I’d prefer to put the code in the scrip
and let the template just handle formatting the mail, but I don’t
know how to get the custom action to generate an e-mail using the
template. Is there a command like “RT::SendEmailUsingScripTemplate”?

What I’ve done is probably confusing, but it’s like this:

  1. Mail comes in to queue 1. A scrip extracts some data and
    populates some custom fields, sets the priority, and moves the
    ticket to queue 2.
  2. Ticket enters queue 2. Scrip fires and uses Notify Others action
    to “launch” a template.
  3. Template modifies some fields in the ticket and creates e-mail to
    action address.
  4. Action address does their job and replies to mail with
    “ok”. Scrip in queue 2 triggers, modifies some fields in the
    ticket, moves ticket back to queue 1.
  5. Lather, rinse, repeat a couple more times.

What I want to do is take the code that modifies the ticket out of
the template at step 3 and put it into the scrip at step 2, but I
don’t know how to get the scrip to use the template after making the
changes to the ticket. I thought that putting the code in the prep
code and returning a “1” would do it, but nothing happens with the template.

Gene,

Maybe it’s because it’s Monday morning, but I wasn’t thinking clearly
when I wrote earlier - I apologize. I don’t actually know how to make
a custom action generate an email message that will use the scrip
template. As Torsten said I think there’s something on the wiki, but
I couldn’t find it.

You could put your code into a custom condition instead of a custom action.

Or you could create a new action in the lib/Actions directory and
insert into the ScripActions table to make this available as a scrip
action in the UI. There’s an example of this on the wiki:
Request Tracker Wiki but I
haven’t used this particular piece of code.

Steve