]> git.evergreen-ils.org Git - working/Evergreen.git/blob - docs/admin/actiontriggers.txt
(doc) 'debian-wheezy' was left out of the OS options
[working/Evergreen.git] / docs / admin / actiontriggers.txt
1 Action Triggers
2 ---------------
3
4 indexterm:[action triggers, event definitions]
5
6 Action Triggers give administrators the ability to set up actions for
7 specific events. They are useful for notification events such as hold notifications.
8
9 To access the Action Triggers module, select *Admin* -> *Local Administration* -> *Notifications / Action triggers*.
10
11 [NOTE]
12 ==========
13 You must have Local Administrator permissions to access the Action Triggers module.
14 ==========
15
16 You will notice four tabs on this page: <<event_definitions, Event Definitions>>, <<hooks, Hooks>>, <<reactors, Reactors>> and <<validators, Validators>>.
17
18
19 anchor:event_definitions[]
20
21 Event Definitions
22 ~~~~~~~~~~~~~~~~~
23
24 Event Definitions is the main tab and contains the key fields when working with action triggers. These fields include:
25
26 Table 1: Action Trigger Event Definitions
27 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 |==============================================
29 |*Field*                         |*Description*
30 | Owning Library                 |The shortname of the library for which the action / trigger / hook is defined.
31 | Name                           |The name of the trigger event, that links to a trigger event environment containing a set of fields that will be returned to the <<validators, Validators>> and/or <<reactors, Reactors>> for processing.
32 | <<hooks, Hook>>                |The name of the trigger for the trigger event. The underlying action_trigger.hook table defines the Fieldmapper class in the core_type column off of which the rest of the field definitions ``hang''.
33 | Enabled                        |Sets the given trigger as enabled or disabled. This must be set to enabled for the Action trigger to run.
34 | Processing Delay               |Defines how long after a given trigger / hook event has occurred before the associated action (``Reactor'') will be taken.
35 | Processing Delay Context Field |Defines the field associated with the event on which the processing delay is calculated. For example, the processing delay context field on the hold.capture hook (which has a core_type of ahr) is _capture_time_.
36 | Processing Group Context Field |Used to batch actions based on its associated group.
37 | <<reactors, Reactor>>          |Links the action trigger to the Reactor.
38 | <<validators, Validator>>      |The subroutines receive the trigger environment as an argument (see the linked Name for the environment definition) and returns either _1_ if the validator is _true_ or _0_ if the validator returns _false_.
39 | Event Repeatability Delay      |Allows events to be repeated after this delay interval.
40 | Granularity                    |Used to group events by how often they should be run. Options are Hourly, Daily, Weekly, Monthly, Yearly, but you may also create new values.
41 |===============================================
42
43
44 Creating Action Triggers
45 ~~~~~~~~~~~~~~~~~~~~~~~~
46 . From the top menu, select *Admin* -> *Local Administration* -> *Notifications / Action triggers*.
47 . Click on the _New_ button.
48 . Select an _Owning Library_.
49 . Create a unique _Name_ for your new action trigger.
50 . Select the _Hook_.
51 . Check the _Enabled_ check box.
52 . Set the _Processing Delay_ in the appropriate format. Eg. _7 days_ to run 7 days from the trigger event or _00:01:00_ to run 1 hour after the _Processing Delay Context Field_.
53 . Set the _Processing Delay Context Field_ and _Processing Group Context Field_.
54 . Select the _Reactor_, _Validator_, _Failure Cleanup_.
55 . Select the _Granularity_.
56
57 . Set the _Max Event Validity Delay_.
58
59 . Select the _Opt-In Setting Type_.
60
61 . Set the _Opt-In User Field_.
62
63 . Select the _Success Cleanup_.
64
65 . Enter text in the _Template_ text box if required. These are for email messages. Here is a sample template for sending 90 day overdue notices:
66
67
68   [%- USE date -%]
69   [%- user = target.0.usr -%]
70   To: [%- params.recipient_email || user.email %]
71   From: [%- params.sender_email || default_sender %]
72   Subject: Overdue Items Marked Lost
73
74   Dear [% user.family_name %], [% user.first_given_name %]
75   The following items are 90 days overdue and have been marked LOST.
76   [%- params.recipient_email || user.email %][%- params.sender_email || default_sender %]
77   [% FOR circ IN target %]
78     Title: [% circ.target_copy.call_number.record.simple_record.title %]
79     Barcode: [% circ.target_copy.barcode %]
80     Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
81     Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
82     Total Owed For Transaction: [% circ.billable_transaction.summary.total_owed %]
83     Library: [% circ.circ_lib.name %]
84   [% END %]
85
86   [% FOR circ IN target %]
87     Title: [% circ.target_copy.call_number.record.simple_record.title %]
88     Barcode: [% circ.target_copy.barcode %]
89     Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
90     Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
91     Total Owed For Transaction: [% circ.billable_transaction.summary.total_owed %]
92     Library: [% circ.circ_lib.name %]
93   [% END %]
94
95 . Once you are satisfied with your new event trigger, click the _Save_ button located at the bottom of the form.
96
97 [TIP]
98 =========
99 A quick and easy way to create new action triggers is to clone an existing action trigger.
100 =========
101
102 Cloning Existing Action Triggers
103 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104
105 . Check the check box next to the action trigger you wish to clone.
106 . Click _Clone Selected_ on the top left of the page.
107 . An editing window will open. Notice that the fields will be populated with content from the cloned action trigger. Edit as necessary and give the new action trigger a unique Name.
108 . Click _Save_.
109
110 Editing Action Triggers
111 ^^^^^^^^^^^^^^^^^^^^^^^
112
113 . Double-click on the action trigger you wish to edit.
114 . The edit screen will appear. When you are finished editing, click _Save_ at the bottom of the form. Or click _Cancel_ to exit the screen without saving.
115
116 [NOTE]
117 ============
118 Before deleting an action trigger, you should consider disabling it through the editing form. This way you can keep it for future use or cloning.
119 ============
120
121 Deleting Action Triggers
122 ^^^^^^^^^^^^^^^^^^^^^^^^
123
124 . Check the check box next to the action trigger you wish to delete
125 . Click _Delete Selected_ on the top-right of the page.
126
127
128 anchor:hooks[]
129
130 Hooks
131 ^^^^^
132 Hooks define the Fieldmapper class in the core_type column off of which the rest of the field definitions ``hang''.
133
134 Table 2. Hooks
135 ++++++++++++++
136 |=======================
137 | *Field*        | *Description*
138 | Hook Key       | A unique name given to the hook.
139 | Core Type      | Used to link the action trigger to the IDL class in fm_IDL.xml
140 | Description    | Text to describe the purpose of the hook.
141 | Passive        | Indicates whether or not an event is created by direct user action or is circumstantial.
142 |=======================
143
144 You may also create, edit and delete Hooks but the Core Type must refer to an IDL class in the fm_IDL.xml file.
145
146
147 anchor:reactors[]
148
149 Reactors
150 ^^^^^^^^
151
152 Reactors link the trigger definition to the action to be carried out.
153
154 Table 3. Action Trigger Reactors
155 ++++++++++++++++++++++++++++++++
156
157 |=======================
158 | Field        | Description
159 | Module Name  | The name of the Module to run if the action trigger is validated. It must be defined as a subroutine in `/openils/lib/perl5/OpenILS/Application/Trigger/Reactor.pm` or as a module in `/openils/lib/perl5/OpenILS/Application/Trigger/Reactor/*.pm`.
160 | Description  | Description of the Action to be carried out.
161 |=======================
162
163 You may also create, edit and delete Reactors. Just remember that there must be an associated subroutine or module in the Reactor Perl module.
164
165
166 anchor:validators[]
167
168 Validators
169 ^^^^^^^^^^
170
171 Validators set the validation test to be preformed to determine whether the action trigger is executed.
172
173 Table 4. Action Trigger Validators
174 ++++++++++++++++++++++++++++++++++
175
176 |=======================
177 | Field         | Description
178 | Module Name   | The name of the subroutine in `/openils/lib/perl5/OpenILS/Application/Trigger/Reactor.pm` to validate the action trigger.
179 | Description   | Description of validation test to run.
180 |=======================
181
182 You may also create, edit and delete Validators. Just remember that their must be an associated subroutine in the Reactor.pm Perl module.
183
184 Processing Action Triggers
185 ~~~~~~~~~~~~~~~~~~~~~~~~~~
186
187 To run the action triggers, an Evergreen administrator will need to run the trigger processing script. This should be set up as a cron job to run periodically. To run the script, use this command:
188
189 ----
190 /openils/bin/action_trigger_runner.pl --process-hooks --run-pending
191 ----
192
193 You have several options when running the script:
194
195 * --run-pending: Run the pending events
196
197 * --process-hooks: Create hook events
198
199 * --osrf-config=[config_file]: OpenSRF core config file. Defaults to: /openils/conf/
200 opensrf_core.xml.
201
202 * --custom-filters=[filter_file]: File containing a JSON Object which describes any hooks
203 that should use a user-defined filter to find their target objects. Defaults to: /openils/conf/
204 action_trigger_filters.json
205
206 * --max-sleep=[seconds]: When in process-hooks mode, wait up to [seconds] for the lock file to go
207 away. Defaults to 3600 (1 hour).
208
209 * --hooks=hook1[,hook2,hook3,...]: Define which hooks to create events for. If none are defined, it
210 defaults to the list of hooks defined in the --custom-filters option.
211
212 * --debug-stdout: Print server responses to STDOUT (as JSON) for debugging.
213
214 * --lock-file=[file_name]: Sets the lock file for the process.
215
216 * --help: Show help information.
217