[rt-users] scrips and dynamic templates

Ruslan U. Zakirov cubic at acronis.ru
Wed Jun 23 07:54:19 EDT 2004


Bob Goldstein пишет:
> 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.)

http://wiki.bestpractical.com/index.cgi?HowTos

> 
> 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.
When you put condition into module under .../lib/RT/Condition/ then you 
should register this module in DB.

> 
> * 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" ?
Last. Only if "UserDefined"
> 
> * I presume "Custom action preparation" and "Custom action cleanup"
>   run before and after the selected action from the dropdown box?
No. RT doesn't support running scrip code before action.
http://wiki.bestpractical.com/index.cgi?ScripExecOrder

> 
> * 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?
In 3.0.x stage select box appear by incident :) I can't explain all 
issues you should look at source code. Patch was on devel list and was 
approved for 3.2. I hope it's there :) didn't look yet.

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

> 
> * 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 ?)
One of the most desired feature. Dirk Pape has patch that add this feature.

> 
> 
> 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
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> RT Developer and Administrator training is coming to LA, DC and Frankfurt this spring and summer.
> http://bestpractical.com/services/training.html
> 
> Sign up early, as class space is limited. 




More information about the rt-users mailing list