[Evergreen-general] An action trigger for sending emails after bib records are created?

Linda Jansová linda.jansova at gmail.com
Wed Jun 29 10:58:47 EDT 2022


Dear all,

We are trying to make our action triggers work - we are on a 3.6 system 
and so far we have not found a working solution for a trigger that would 
send an email after a bib record is created.

As we suspect that there might be something wrong with our crontab, 
attached is its current crontab setup.

Bellow are two action triggers which we have (both unsuccessfully) 
tried. The first one uses our original template code (which - for some 
reason - had worked before we upgraded to 3.6 last year) and the second 
one uses the template code from a 3.9 community demo system 
(https://demo.evergreencatalog.com/eg2/en-US/staff/admin/local/action_trigger/event_definition/31). 
I am well aware that there is a version mismatch in the second case but 
we decided to at least give it a try before digging deeper.

**

*Action trigger with original template code and settings (Evergreen 3.6):*

*Owning Library: *CONS*
Name:* biblio.record_entry.email*
Hook: *biblio.format.record_entry.email*
Enabled:* ticked*
Processing Delay:* 00:00:00*
Processing Delay Context Field:* empty*
Processing Group Context Field:* owner*
Reactor:* SendEmail*
Validator:* NOOP_True*
Event Repeatability Delay:* empty

***Definition ID:* 165*
Failure Cleanup:* DeleteTempBiblioBucket*
Granularity:* empty*
Max Event Validity Delay:* empty*
Message Library Path:* empty*
Message Template:* empty*
Message Title:* empty*
Message User Path:* empty*
Opt-In Setting Type:* empty*
Opt-In User Field:* empty*
Retention Interval:* empty*
Success Cleanup:* DeleteTempBiblioBucket*
Template:*

[%- SET user = target.0.owner -%]

To: [%- params.recipient_email || user.email %]

From: [%- params.sender_email || default_sender %]

Subject: Informace o dokumentech v katalogu


[% FOR cbreb IN target %][% title = '' %]

[% FOR item IN cbreb.items;

bre_id = item.target_biblio_record_entry;


bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});

FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');

title = title _ part.textContent;

END;


author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;

item_type = 
bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');

publisher = bibxml.findnodes('//*[@tag="260" or 
@tag="264"]/*[@code="b"]').textContent;

pubdate = bibxml.findnodes('//*[@tag="260" or 
@tag="264"]/*[@code="c"]').textContent;

isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;

issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;

upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;

%]


Číslo záznamu [% bre_id %]

[% title %] [% author %]

[% publisher %] [% pubdate %]

[% IF isbn %]ISBN: [% isbn %][% END %][% IF issn %]ISSN: [% issn %][% END %]

Odkaz na záznam ve Společném katalogu Evergreen: 
http://spok.jabok.cuni.cz/eg/opac/record/[% bre_id %]

[% END %]

[% END %]




-----------

TIP: Odkaz na záznam(y) v katalogu vaší knihovny:


Pokud chcete vytvořit odkaz na knihu/dokument přímo do katalogu vaší 
knihovny, přidejte čísla záznamu na konec níže uvedeného URL vaší 
knihovny (za poslední lomítko):

- Knihovna Jabok: https://knihovna.jabok.cuni.cz/eg/opac/record/

- Evangelikální teologický seminář: 
https://ets.jabok.cuni.cz/eg/opac/record/

- Jáchymka: https://jachymka.jabok.cuni.cz/eg/opac/record/

- Katolický domov studujících: https://kds.jabok.cuni.cz/eg/opac/record/

- Člověk v tísni: https://clovekvtisni.jabok.cuni.cz/eg/opac/record/

- Hospic Dobrého Pastýře: https://dobrypastyr.jabok.cuni.cz/eg/opac/record/



*Action trigger with template code from the community demo server 
(Evergreen 3.9):*

*Owning Library:* CONS*
Name:* BibliografickeZaznamyEmail*
Hook:* biblio.format.record_email

*Enabled:* ticked*
Processing Delay:* 00:00:00*
Processing Delay Context Field:* empty*
Processing Group Context Field:* owner*
Reactor: *SendEmail*
Validator:* NOOP_True*
Event Repeatability Delay:* empty*
Definition ID:* 213*
Failure Cleanup:* DeleteTempBiblioBucket*
Granularity:* empty*
Max Event Validity Delay:* empty*
Message Library Path:* empty*
Message Template:* empty*
Message Title:* empty*
Message User Path:* empty*
Opt-In Setting Type:* empty*
Opt-In User Field:* empty*
Retention Interval:* empty*
Success Cleanup:* DeleteTempBiblioBucket*
Template:*

[%- USE date -%]

[%- SET user = target.0.owner -%]

To: [%- params.recipient_email || user_data.0.email || user.email %]

From: [%- params.sender_email || default_sender %]

Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]

Subject: [%- user_data.0.subject || 'Bibliographic Records' %]

Auto-Submitted: auto-generated


[%- FOR cbreb IN target;


flesh_list = '{mra';

IF user_data.0.type == 'full';

flesh_list = flesh_list _ ',holdings_xml,acp';

IF params.holdings_limit;

flimit = 'acn=>' _ params.holdings_limit _ ',acp=>' _ params.holdings_limit;

END;

END;

flesh_list = flesh_list _ '}';


item_list = helpers.sort_bucket_unapi_bre(cbreb.items,{flesh => 
flesh_list, site => user_data.0.context_org, flesh_limit => flimit}, 
user_data.0.sort_by, user_data.0.sort_dir);


FOR item IN item_list -%]


[% loop.count %]/[% loop.size %]. Bib ID# [% item.id %]

[% IF item.isbn %]ISBN: [% item.isbn _ "\n" %][% END -%]

[% IF item.issn %]ISSN: [% item.issn _ "\n" %][% END -%]

[% IF item.upc %]UPC: [% item.upc _ "\n" %][% END -%]

Title: [% item.title %]

[% IF item.author %]Author: [% item.author _ "\n" %][% END -%]

Publication Info: [% item.publisher %] [% item.pubdate %]

Item Type: [% item.item_type %]

[% IF user_data.0.type == 'full' && item.holdings.size == 0 %]

* No items for this record at the selected location

[%- END %]

[% FOR cp IN item.holdings -%]

* Library: [% cp.circ_lib %]

Location: [% cp.location %]

Call Number: [% cp.prefix _ ' ' _ cp.callnumber _ ' ' _ cp.suffix %]

[% IF cp.parts %] Parts: [% cp.parts _ "\n" %][% END -%]

Status: [% cp.status_label %]

Barcode: [% cp.barcode %]


[% END -%]

[%- END -%]

[%- END -%]


Do you have any idea about what might be preventing the trigger from 
working properly? Or could you please share your working config?

Or is there a way to switch on a debug mode in logging that could shed 
more light on what is happening in our system when it comes to action 
triggers and emails?

Thank you very much for any hints!

Linda

**
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.evergreen-ils.org/pipermail/evergreen-general/attachments/20220629/6650e3a7/attachment-0001.htm>
-------------- next part --------------
# Evergreen crontab.example
# Author: Joe Atzberger, ESI
# Author: Bill Erickson, ESI
#
# This is an example of a crontab file for Debian.  It may not work 
# in other versions of crontab, like on Solaris 8 or BSD, for example.
# 
# While similar in structure, 
# this is NOT an example for cron (as root).  Cron takes an extra
# argument per line to designate the user to run as.  You could 
# reasonably extrapolate the needed info from here though.
#
# WARNING: These jobs will do things like charge fines, send
# potentially VERY MANY emails to patrons and even debar offending
# users.  DO NOT RUN OR SCHEDULE these jobs without being sure you
# really intend to.  Make sure the relevant message templates are
# configured to your liking before scheduling messages to be sent.
#
# Except where indicated, these processes only need to run 
# on 1 Evergreen server/brick.


# ENVIRONMENT:
# First, establish Evergreen ENV variables.
#
OPENILS    = /openils
SRF_CORE   = /openils/conf/opensrf_core.xml
EG_BIN_DIR = /openils/bin

# crontab format:
# m h dom mon dow   command

# Run the hold targeter
*/15 * * * *   . ~/.bashrc && $EG_BIN_DIR/hold_targeter.pl --osrf-config $SRF_CORE

# Run the hold thawer
5  0  * * *   . ~/.bashrc && $EG_BIN_DIR/thaw_expired_frozen_holds.srfsh

# Generate fines
30 0  * * *   . ~/.bashrc && $EG_BIN_DIR/fine_generator.pl $SRF_CORE

# Run the reshelving completer
2  0  * * *   . ~/.bashrc && $EG_BIN_DIR/reshelving_complete.srfsh

# Run the pending user purger
30 2  * * *   . ~/.bashrc && $EG_BIN_DIR/purge_pending_users.srfsh

# create the list of blocked patrons for offline use
# Note: The resulting list.txt file needs to be copied to all Apache servers
30 6  * * *   . ~/.bashrc && $EG_BIN_DIR/offline-blocked-list.pl $SRF_CORE > $OPENILS/var/web/standalone/list.txt

# Restart SIP nightly to free up any orphaned processes.  
# Note: Run on all SIP servers
# 5  2  * * *   . ~/.bashrc && oils_ctl.sh -d $OPENILS/var/pid -s $OPENILS/conf/oils_sip.xml -a stop_sip
# 8  2  * * *   . ~/.bashrc && oils_ctl.sh -d $OPENILS/var/pid -s $OPENILS/conf/oils_sip.xml -a start_sip

# Run the circ history cleanup job
# Note: destroys link between user and item
#2  0  * * *   . ~/.bashrc && $EG_BIN_DIR/clear_expired_circ_history.srfsh

# Run the hard due date updater
2  3  * * *   . ~/.bashrc && $EG_BIN_DIR/update_hard_due_dates.srfsh

# Run the carousel updater
5  3  * * *   . ~/.bashrc && $EG_BIN_DIR/refresh_carousels.srfsh

# Run the credit card number clearing script
#5  4  * * *   . ~/.bashrc && $EG_BIN_DIR/clear_cc_number.srfsh

# Calculate scores for popularity badges
#30 4 * * * . ~/.bashrc && $EG_BIN_DIR/badge_score_generator.pl $SRF_CORE

# Action/Trigger entries ----

# Runs all pending A/T events every half hour - chaned to 5 mins
*/5 * * * * . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --run-pending

# Passive A/T event generation.
# Note: push these back to 3am so they will run after the fine generator and spread out the start minute to reduce dogpiling
0 * * * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity hourly
5 3 * * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity Daily
10 3 * * 1-5 . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity weekdays
15 3 * * 0   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity weekly
20 3 1 * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity monthly
25 3 1 1 *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity yearly

# Custom cron 
1 4 * * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --hooks=checkout.due --process-hooks --granularity daily --run-pending
5 4 * * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --hooks=checkout.due --process-hooks --granularity Daily --run-pending
10 4 * * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --hooks=checkout.due --process-hooks --run-pending
7 4 * * *   . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --hooks=hold_request.shelf_expires_soon --process-hooks --granularity Daily --run-pending


# Purge old A/T events
15 1  * * *   . ~/.bashrc && $EG_BIN_DIR/purge_at_events.srfsh

# Legacy overdue/predue notice generator.  Change to suit.
#XML_FILE_PREFIX = /openils/var/data/overdue/overdue
#0 3 * * * . ~/.bashrc && cd $EG_BIN_DIR && ./generate_circ_notices.pl --osrf_config $SRF_CORE --notice-types overdue,predue --generate-global-templates --send-email > $XML_FILE_PREFIX.$(date +"\%F").xml

# TODO: add other entries




More information about the Evergreen-general mailing list