[rt-users] scrips and dynamic templates

Bob Goldstein bobg at uic.edu
Sun Jun 20 13:45:18 EDT 2004


My original goal was to change the scrip "On Create Autoreply To
Requestors with template Autoreply".

I want to use one template if a certain custom field were non-null,
and the normal Autoreply template for the default case. And, I
thought I should do this for some queues, not all. (BTW, I have
modified the email internal code so it can parse the incoming
email for special commands and create a CF if needed. This is all
based on an RT2 mailgate for giving commands with email, worked
up for RT3. So in fact, the CF can exist during the initial
create transaction.)

I read through what docs (and wiki) I could find, but they seem a
bit sketchy. So I'd like to have some assertions confirmed, as
well as ask advice. (Sorry for the long note. If I can assemble
enough info, I'll write a wiki article to help others that reach
my state of befuddlement.)

* The <NotResolved> wiki page talks about creating a scrip condition
  by adding code into a directory such as rt/local/lib/RT/Condition/

  Whereas most of the other comments have to do with putting custom
  code in the web page under "Scrips".

  Assertion 1: Filling out the web page puts the code into
    the database.  Obviously, writing new code in 
    rt/local/lib/RT/Condition/ does not.

  Assertion 2: Writing a new condition into rt/local/lib/RT/Condition/
    would affect that condition *only*, and therefore all scrips
    that use that condition.  Whereas putting a new condition
    into the database goes into the table Scrips, as opposed
    to ScripConditions, and therefore affects only the
    single condition-action-template combination specified.

* If I write a custom condition on the web page, is that ANDed
  with something else like "OnCreate", or does it only apply
  at all if I choose "UserDefined" ?

* I presume "Custom action preparation" and "Custom action cleanup"
  run before and after the selected action from the dropdown box?

* The database schema has columns for ConditionRules and ActionRules.
  I can't match them to what I see on the web page.  Are they used?

* What is a "stage", and what is the difference between TransactionCreate
  and TransactionBatch?

* Are templates a strictly replace-the-variables kind of template,
  or can I have branches or loops, as with Template::Toolkit?

* Can I override or turn off a Global Scrip for a specific queue? 
  I'd prefer not to have to turn off the scrip globally,
  because then I'd have to define the replacement for every
  queue, including the ones I haven't created yet.  (Is there
  a condition OnQueueCreate ?)


Ok, now for the advice. I see several potential options.
Which is cleanest?

  1. Modify template with a branch, depending on value of
     a custom field.  If so, how?

  2. Modify condition so that it somehow dynamically modifies
     the scrip it is in, to choose one template or the other.

  3. Replace the Autoreply scrip with two scrips,
        OnCreate with CF-non-null, use template Autoreply-special
        OnCreate with CF--null, use template Autoreply-default

     (And can I add the CF check to the existing OnCreate condition,
      or do I have to fully make new conditions?)

  
Thanks much for any help.

    bobg



More information about the rt-users mailing list