Borrower Notification Preferences
I'm trying to set up the system to send overdues by e-mail where the borrower has a preference.
I have added 'POST' and 'EMAIL' to the borrower analysis parameters, and I have set up a test overdue on a borrower with a preference of 'EMAIL', and added an e-mail address to his borrower record.
I have installed the local perl tool, GetBorrowerNotification.
I have set up a test ovedue script (based on the loa_odue_letter_ftr script which we use) and I have altered the select.pl to include:
-----------------------------------------
sub select
{
require "/users/report/mis/local_perl_tool/get_borrower_notification.pl";
GetBorrowerNotification($BorrowerId,'POST');
if ($notification ne 'POST')
{
return 0;
}
-----------------------------------------
and I have altered the format.pl to include the email field.
-----------------------------------------
format LETTER1 =
@<<<<<<<<<<<<<<<<<<<<<~
$BorrowerFullName
@<<<<<<<<<<<<<<<<<<<<<~
$BorrowerAddressLine1
@<<<<<<<<<<<<<<<<<<<<<~, @<<<<<<<<<<<<<<<<<<<<<~
$BorrowerAddressLine2 $BorrowerAddressLine3
@<<<<<<<<<<<<<<<<<<<<<~
$BorrowerAddressPostCode
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$EmailAddress1
Number: @<<<<<<<<<<<<< Dated: @<<<<<<<<<<<<<<<<<
$BorrowerBarcode $ShortCurrentDate
Branch: @<<<<<<<<<<<<<<<<<~ Phone: @<<<<<<<<<<<<<<<<<~
$LocationAddressLine1 $LocationAddressPhoneNo
======================================================
FIRST OVERDUE
.
-----------------------------------------
However, when I run the overdue script, halfway through, it churns out the following error message:
Sybase message 156, Severity 15, state 1
Server `SYBASE'
Line 5
Incorrect syntax near the keyword 'and'.
1>
2> select GROUPING_ID
3> from BORROWER_GROUPING_LINK
4> where BORROWER_ID =
5> and SUB_TYPE = 1
6> and GROUPING_ID in ('POST','EMAIL')
It looks to me like the $bor_id is not being passed from the perl tool, but I don't really understand perl, so I'm not sure what the problem is....
Would I need to populate everyones borrower record with either 'POST' or 'EMAIL', or is the select.pl script supposed to default to 'POST' if one isn't present.
If this makes sense to anyone, do you have any ideas why it's failing?
Cheers
Mark



Borrower Notification Preference
Just in case it helps, here's the bit I changed in the retrieve.pl from the overdue script:
sub retrieve_data
{
&sql($d, "set dateformat dmy");
#
# Get borrower name and address details
#
# Programmer debug
&GetBorrowerDetails($bor_id);
if ($notification eq 'POST')
{
$EmailAddress1 = "";
}
if ($notification eq 'EMAIL')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
}
$initial = substr($BorrowerFirstNames, 0, 1);
$BorrowerFullName = "$BorrowerStyle $initial. $BorrowerSurname";
#
# Get library location
#
and so on...........
http://www.wirral-libraries.net/
http://www.stembystem.co.uk/
borrower preferences
In the local perl tool you used the variable $BorrowerId e.g.
GetBorrowerNotification($BorrowerId,'POST');
However in the loa_odue_letter_ftr the BORROWER_ID values are held in the $bor_id variable. As the $BorrowerId variable is not used in the loa_odue_letter_ftr script it has no value (PERL does not require you to declare or define a variable before you use it) then no value is passed into the SQL so it is looking for BORROWER_ID = e.g. with no ID value.
As the scripts have developed over time the same variable names have not been used from script to script so it is always necessary to check a variable name as it may differ from the examples given.
I think if you use the following it should work (or at least the local perl tool will return a value):
GetBorrowerNotification($bor_id,'POST');
The 'POST' section of the local perl tool is the default value so if a borrower does not have one of the values (TELE,POST,MAIL) or more than one then POST would be returned. You can change this default if required. It is possible to change the codes within the perl tool but that is another issue.
Thanks
Brian Crampton
Developer, Talis
Thanks Brian
Thanks Brian, changing the $BorrowerId to $Bor_id worked.
Another problem though, that you may be able to help with is:
In the retrieve.pl, I have the following lines:
&GetBorrowerDetails($bor_id);
if ($notification eq 'POST')
{
$EmailAddress1 = "";
}
if ($notification eq 'EMAIL')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
}
So, if the $notification os 'POST' then the email address is removed, and if it's 'EMAIL' then 'mailto:' is popped at the start if the string.
However, this doesn't seem to work. If it's POST then the email address is not removed, and if it's EMAIL then mailto: is not prefixed.
I have popped $notification and $EmailAddress1 in the format.pl and these appear to be correct for the users. But I can't see why the if statements aren't being done.
Any ideas?
Cheers
Mark
http://www.wirral-libraries.net/
http://www.stembystem.co.uk/
notifications
While the your local versions of the script are using the $bor_id variable I went back to the original script and the variable used with the &GetBorrowerDetails tool is $last_bor_proc.
The reason for this is because of the need to put the borrower details in the footer and the way the borrowers are processed. I'm not sure why this has been changed in your local versions. There may be a reason but I haven't seen why.
Apart from that I'm not sure why there is a problem but the best approach to diagnosing problems is to put trace code into the retrieve.pl to see what the values are at the critical point in the code. Putting the variables in the format is only telling you what the values are at that point and they may not be that.
If you update the retrieve.pl thus
&GetBorrowerDetails($bor_id);
if ($notification eq 'POST')
{
$EmailAddress1 = "";
printf STDERR "POST:Borrower $bor_id Note:$notification Email:$EmailAddress1 \n";
}
if ($notification eq 'EMAIL')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
printf STDERR "EMAIL:Borrower $bor_id Note:$notification email:$EmailAddress1 \n";
}
This will print out trace to the report written to screen and you can check what is actually happening at that point in the code and what paths are being followed.
This should all be done on the MIS server. It is useful to only have a few overdues processed and then reset the LETTER_SNT table e.g. remove the rows you have just created so you can retest more easily.
Thanks
Brian Crampton
Developer, Talis
EMail Revisited...
Brian,
I know it's been a while, but for some reason I never finished this last year, so I'm revisiting it now to see if I can take it further...
I can seem to get everything working as expected e.g. In the retrieve.pl, for testing purposes, I added:
&GetBorrowerDetails($bor_id);
if ($notification eq 'POST')
{
$EmailAddress1 = "";
printf STDERR "POST:Borrower $bor_id Note:$notification Email:$EmailAddress1 \n";
}
if ($notification eq 'EMAIL')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
printf STDERR "EMAIL:Borrower $bor_id Note:$notification email:$EmailAddress1 \n";
}
and from the results, I can see the correct variables are being passed for $notification and $EmailAddress1
e.g.
POST:Borrower 102694 Note:POST Email:
EMAIL:Borrower 103838 Note:EMAIL Email:mailto:markhughes@wirral-libraries.net
POST:Borrower 112002 Note:POST Email:
POST:Borrower 112002 Note:POST Email:
POST:Borrower 112002 Note:POST Email:
However, when I examine the output file, the $EmailAddress1 doesn't come out as expected. It shows as markhughes@wirral-libraries.net, without the 'mailto:' at the front. Also, for any records that had an email address, the email address is also showing in the output, despite the $EmailAddress1 supposedly being blanked for those records with POST in the Borrower Record Analysis code.
Any ideas why the format.pl isn't showing the correct data from the retrieve.pl ?
e.g.
---------------------------------------------------------
Mr M. HUGHES
C/O BIBS
BIRKENHEAD CENTRAL LIBRARY,
markhughes@wirral-libraries.net
Number: 0255125X Dated: 13/06/08
Branch: Birkenhead Central Phone: 0151 652 6106
======================================================
FIRST OVERDUE
Butterwo Thud!
500003838256 Story time 23/05/08
---------------------------------------------------------
Cheers
Mark
http://www.wirral-libraries.net/
I just can't get my head
I just can't get my head around this...
I notice that the FIRST record in my output file is correct, and shows the right $EmailAddress1 values
e.g.
Mrs J. EVANS
99 SOUTH ROAD, NOCTORUM
CH43 7AB
mailto:jevans@testing.co.uk
but, any subsequent output records do not get the 'mailto:' appended to the EMail address.
e.g.
Mr M. HUGHES
C/O BIBS
BIRKENHEAD CENTRAL LIBRARY, BIRKENHEAD
CH42 1XB
markhughes@wirral-libraries.net (*** WITHOUT THE 'mailto: ***)
Any ideas?????
Cheers
Mark
http://www.wirral-libraries.net/
adding notifications
The initial problem is that the line in the select.pl
GetBorrowerNotification($bor_id,'POST');
will not be calling the perl tool. The line needs to start with & to indicate a sub process.
&GetBorrowerNotification($bor_id,'POST');
Sorry I missed that in the earlier postings.
There may also be an issue with generic instructions for specific scripts. Not all the letter scripts operator in same way so changes have to be adjusted.
That section of the loa_odue_letter_ftr is not dealing with borrower details. It is checking whether the loan should be considered for inclusion more generally. The require statement can stay where it is as this only has to be called once. In fact that should probably be in the main.pl but that is not critical.
It is not the best place for the perl tool although in other scripts this may be different.
There is a section loa_odue_letter_ftr where this could be placed but I would insert the line into the retrieve.pl where the borrower details are actually retrieved.
# Programmer debug
&GetBorrowerDetails($bor_id);
&GetBorrowerNotification($bor_id,'POST');
if ($notification eq 'POST')
{
($EmailAddress1) = "";
Try that and see if that solves the issues.
Brian Crampton
Developer, Talis
Brian, Nope, tried that and
Brian,
Nope, tried that and it still doesn't work. It DOES for the first record in the output file, but all subsequent e-mail where the preference (in the borrower analysis field) is EMAIL, do not get the 'mailto:' appended.
The code I have is (I'm trying it on the loa_odue_letter_ftr):
In the select.pl, I just have the line that says:
----------------
Sub Select
{
require "/users/report/mis/local_perl_tool/get_borrower_notification.pl";
At the select.pl, I don't want to reject any records as yet, so I'm not using any additional code here...
In the retrieve.pl, I have the lines:
------------------
# Programmer debug
&GetBorrowerDetails($bor_id);
&GetBorrowerNotification($bor_id,'POST');
if ($notification eq 'POST')
{
($EmailAddress1) = "";
}
if ($notification eq 'EMAIL')
{
($EmailAddress1) = "mailto:" . $EmailAddress1 ;
}
$initial = substr($BorrowerFirstNames, 0, 1);
$BorrowerFullName = "$BorrowerStyle $initial. $BorrowerSurname" ;
($CombinedAddressLine) = $BorrowerAddressLine2 . ", " . $BorrowerAddressLine3 ;
I'm just trying to blank any email addresses where the preference is POST, and append 'mailto:' to any email addresses where the preference is EMAIL.
If I pop in some debug code into the retrieve.pl, e.g.
if ($notification eq 'POST')
{
($EmailAddress1) = "";
printf STDERR "POST:Borrower $bor_id Note:$notification Email:$EmailAddress1 \n";
}
if ($notification eq 'EMAIL')
{
($EmailAddress1) = "mailto:" . $EmailAddress1 ;
printf STDERR "EMAIL:Borrower $bor_id Note:$notification Email:$EmailAddress1 \n";
}
Then the output to screen at runtime is OK... 'mailto:'does get appended to $EmailAddress1 as expected, but then when I check the output file, only the first overdue record shows mailto:email@address.com, all the others don't get the 'mailto:' appended to them...
Any other ideas?
Cheers
Mark
http://www.wirral-libraries.net/
borrower notifications
I have tested the code on the standard version of the loa_odue_letter_ftr and it works fine.
However you are not running the standard version of the script. In terms of the differences between the two versions the main differences relate to item details and not borrower details but the section below in your local version has
&GetBorrowerDetails($bor_id);
but the standard script has the line
&GetBorrowerDetails($last_bor_proc);
I'm not sure why $bor_id is being used rather than $last_bor_proc but it was probably a mix up between the loa_odue_letter which uses $bor_id and loa_odue_letter which doesn't
The reason for the different variable is that because you are printing the borrower details in the footer when the $bor_id value would have been incremented to the next borrower id.
Can you try the following instead
&GetBorrowerDetails($last_bor_proc);
&GetBorrowerNotification($last_bor_proc,'POST');
Brian Crampton
Developer, Talis
Brian, Thanks for the help.
Brian,
Thanks for the help. I have it working now. It turned out that my predecessor had customised the loa_odue_letter_ftr script and it was this that was throwing me.
I have now used a copy of the default 'loa_odue_letter' instead and it's working fine.
However.....
If I want a different format for the email output, I understand that I have to create 2 scripts... one for post and one for e-mail...
Just looking at the 'post' one, I have the following in my select.pl
sub select
{
require "/users/report/mis/local_perl_tools/get_borrower_notification.pl";
&GetBorrowerNotification($bor_id,'POST');
if ($notification ne 'POST')
{
return 0;
}
However, when I run it I get the message:
Line 5
Incorrect syntax near the keyword 'and'.
1>
2> select GROUPING_ID
3> from BORROWER_GROUPING_LINK
4> where BORROWER_ID =
5> and SUB_TYPE = 1
6> and GROUPING_ID in ('POST','EMAIL')
so I can see that the borrower_id is not being picked up. But in the loa_odue_letter script the borrower_id variable IS bor_id.
Any idea why it's not picking up the id?
Thanks again
Mark
http://www.wirral-libraries.net/
Notification preferences
I'm still puzzled why Talis customers are still having to help each other write different scripts to handle the output from old fixed-purpose perl scripts by different methods, whether it be email, sms, voicemail, IM or RSS - when it should be possible for Talis to produce a standard facility to select output of records, update 'sent message' flags, and conduct a single pass that could be passed to whatever notification format method was required (with different wording for different groups of users or different libraries if needed)but we're still relying on taking the output of one script and running it through another one - all of which takes up valuable machine time as well as systems manager's efforts!
Glyn Sinar
Information & Systems Manager
Lancashire County Library & Information Service
01772 534006
I absolutely agree. In this
I absolutely agree. In this day and age, it should be one of the first features developed... can the powers that be at Talis take a look at this for maybe the next release?
For someone who's not a perl expert, I find the whole thing so fiddly and confusing.
I now have the scripts working to do the e-mailing, but if I want to do a different format for the e-mail, I'll have to create 2 scripts and run the overdues twice, one to post and one to email... does seem to be a waste of machine resources.
Mark
http://www.wirral-libraries.net/
help to get email preference working
I have tried to unpick all the advice from this and other threads and documents and am still getting the error.
Sybase message 156, Severity 15, state 2
Server `SYBASE'
Line 5
Incorrect syntax near the keyword 'and'.
1>
2> select GROUPING_ID
3> from BORROWER_GROUPING_LINK
4> where BORROWER_ID =
5> and SUB_TYPE =1
6> and GROUPING_ID in ('ELEC','POST','TELE')
I have been round in so many circles now that I would like to start the whole thing over again. can you please advise on how to start from scratch to set up sending all current letter and telemessage notices by email as first preference where indicated by the an analysis code.
email preferences
There is no value after the BORROWER_ID = section which is why it failed.
In the Perl script in the statement there would be a variable that holds the BORROWER_ID. The example in the article has $BorrowerId being passed into the new perl tool but as mentioned in the article the variable name used can vary from script to script so the code has to be changed to reflect this.
The easiest way to know what the variable name is for a letter script is to check the value used in the &GetBorrowerDetails Perl tool.
In terms of setting up the process it is a little difficult to give definitive advice as there are a number of variables based on the current scripts used and what is required to be achieved. This is why the article was general rather than specific. You may have multiple local versions of scripts and different outputs for letters and emails and other configurations.
Thanks
Brian Crampton
Developer, Talis
email preferences
Hi Brian
thanks for this......$bor_id is used by &GetBorrowerDetails
sorry this posting looks a bit messy, I'm still thinking that I must be missing something else?
---------------this is what I have in retrieve -------------------
&GetBorrowerDetails($bor_id);
&GetBorrowerNotification($bor_id,'POST');
if ($notification eq 'POST')
{
$EmailAddress1 = "";
printf STDERR "POST:Borrower $bor_id Note:$notification Email:$EmailAddress1 \n";
}
if ($notification eq 'ELEC')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
printf STDERR "EMAIL:Borrower $bor_id Note:$notification email:$EmailAddress1 \n";
}
------------and this is in select.pl---------------------------
require "$TALIS_HOME/perl_tools/get_borrower_notification.pl";
&GetBorrowerNotification ($bor_id, 'POST');
if ($notification ne 'ELEC')
{
return 0;
}
------------get_borrower_notification.pl -------------------
sub GetBorrowerNotification
{
local($bor_id, $default) = @_;
local($count) = 0 ;
local(@temp) = "";
#
# count number of rows in BORROWER_GROUP_LINK for a borrower
#
(@temp) = &sql($d,"
select GROUPING_ID
from BORROWER_GROUPING_LINK
where BORROWER_ID = $bor_id
and SUB_TYPE =1
and GROUPING_ID in ('ELEC','POST','TELE')
");
$count = @temp;
if ($count == 1)
{
($notification) = $temp[0];
}
else
{
($notification) = $default;
}
($notification) = despace($notification);
}
1;
-------------e.g from GetBorrowerDetails---------------
sub GetBorrowerDetails
{
local($bor_id) = @_;
local($temp1, $temp2, $address_id) = 0;
local(@address_ids) = ();
local(@emails) = ();
#
# Get the address_id for the borrower
#
(@address_ids) = &sql($d,"
select ADDRESS_ID
from CONTACT_POINT
where BORROWER_ID = $bor_id
and START_DATE =
( select max(START_DATE)
from CONTACT_POINT
where BORROWER_ID = $bor_id
and START_DATE <= getdate()
and END_DATE >= getdate()
email notifications
The GetBorrowerDetails perl tool is a standard one and the $bor_id variable is only used within that perl tool to hold the value being passed into the perl tool so that variable does not matter in this context.
Now a variable will be used to pass a borrower id value into the perl tool but not the variable name itself. The fact that they are the same in this case is not relevant.
The positioning of the GetBorrowerNotification perl tool is important but will vary to a degree from script to script. While there are similarities between scripts and many common components they are not always used exactly the same way because what is being processed is different.
You have used the GetBorrowerNotification perl tool twice. I don't think there is an issue with the call in the retrieve.pl but in the select.pl
The preselect does not retrieve the BORROWER_ID. What it does is call the LOAN_ID, STATE, CREATE_DATE and DUE_DATE. These values are then passed into the select.pl into a function called select.
This is where you have the GetBorrowerNotification perl tool but at this point the $bor_id varaible has not had any value assigned to it. Perl doesn't require you to define a variable before you use it so if a variable is used without assigning a value then it will still be used but without a value and hence why you are seeing the error.
Now the select function is only checking a loan based on the preselect values. If the loan passes the checks another function, &send_letter is called within the select.pl.
This function does further checks including on the borrower attached to the loan and this is the section where you need to do the borrower checks.
#
# Retrieve more information form LOAN
#
($more_loan) = &sql($d, "select BORROWER_ID,CREATE_LOCATION,
ITEM_ID, LOAN_TYPE
from LOAN
where LOAN_ID = $loanid
and CURRENT_LOAN = 'T' ");
($bor_id, $createloc, $itemid, $loantype) =
&despace(split("~", $more_loan));
&GetBorrowerNotification ($bor_id, 'POST');
if ($notification ne 'POST')
{
$to_send = 0;
}
I've shown the existing section of code that must precede the new code.
There is a different variable that indicates failure, $to_send. You don't need to have a require statement for the new perl tool as that has already been set in the main.pl file. It only has to be done once.
Thanks
Brian Crampton
Developer, Talis
email notifications recall notices
Hi Brian
Thanks very much for your help and patience. I think I’ve now got the overdue scipt working, I still need to test some more but it seems to be creating a .out file with only those borrowers who have the analysis code ELEC. I’ve now moved on to the recall notices and encountered some more problems.
Below is an outline of what I have tried:
1. Copied the contents of rec_long_soon_letter_public directory to a new directory called rec_long_soon_email
2. Edited retrieve.pl to add the &GetBorrowerNotification lines , this retrieve.pl is different to the overdues retrieve.pl but I added the lines after the &GetBorrowerDetails
ADDR.LINE_5,
ADDR.POST_CODE
from ADDRESS ADDR,
CONTACT_POINT COP
/* ADD/COP link */
where ADDR.ADDRESS_ID =
COP.ADDRESS_ID
/* borrower */
and COP.BORROWER_ID = $BorrId
/* get current address */
and COP.CURRENT_CONTACT_POINT
= 'T'
");
($BorrAddr1,$BorrAddr2,$BorrAddr3,$BorrAddr4,$BorrAddr5,
$BorrAddrPostCode) = &despace(split '~', $data);
&GetBorrowerDetails ($BorrId); # IEO 20-05-04 for email
&GetBorrowerNotification($bor_id,'POST');
if ($notification eq 'POST')
{
$EmailAddress1 = "";
printf STDERR "POST:Borrower $bor_id Note:$notification Email:$EmailAddress1 \n";
}
if ($notification eq 'ELEC')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
printf STDERR "EMAIL:Borrower $bor_id Note:$notification email:$EmailAddress1 \n";
}
&modify_address_lines();
}
#
# Get item's class number
3. Preselect does not appear to be used by the recall script so I copied the telemessage param files and created a param file for rec_long_soon_email for each loan period and included the correct paths to the rec_long_soon_email scripts
4. I added the require line for &GetBorrowerDetails to main.pl
require "$TALIS_HOME/perl_tools/std_new_page_win.pl";
require "$TALIS_HOME/perl_tools/local_utils.pl";
require "$TALIS_HOME/perl_tools/adjustMailto.pl";
require "$TALIS_HOME/perl_tools/get_borrower_notification.pl";
I also checked that local_utils.pl included the tools listed
5. Added $EmailAddress1 to format.pl
6. this is where I can’t work out where to add the
&GetBorrowerNotification ($bor_id, 'POST');
if($notification ne 'ELEC')
lines to select.pl as it is very different to the overdues select.pl . I tried adding as below but I don’t think this is right really. It runs without errors but I don’t think it is actually checking the analysis code. ( I would appreciate help to work out how to test, see comments later!)
# Check to see if we have any items to recall
#
if (! scalar @item_loans)
{
$Test = 0;
return ($Test, 0,0,0,0,0,0,0,0,0,0,0,0,0);
}
&GetBorrowerNotification ($bor_id, 'POST');
if($notification ne 'ELEC')
{
$Test = 0;
return ($Test, 0,0,0,0,0,0,0,0,0,0,0,0,0);
}
#
# Get item on loan longest/due back soonest
#
Can you help again please and many apologies for my struggles with PERL
The other problem that I have is how to test the recall scripts. Testing overdues was simple in that I ran a query to identify by barcode the borrowers who had overdues generated the previous day, added the relevant analysis code to a number of these borrowers in Alto connected to the prod_talis on MIS, deleted the lines from LETTER_SNT on MIS for the previous day, then ran the script and checked the results. Resetting the recalls appears not to be so simple. Just deleting the lines from LETTER_SNT does not reset the recall count for the borrower. I’ve noticed that in the article on resetting the LETTERS_SNT table this is referred to so I guess that this is not a simple situation to re-create. Can you suggest a way to test please?
Many thanks
Lin
rec_long_soon _letter and notifications
Lin,
Part of the problem is that the lines you are adding with the borrower ID value use $bor_id as the varaible name but in the rec_long_soon_letter uses $BorrId as the variable name i.e.
&GetBorrowerDetails ($BorrId); # IEO 20-05-04 for email
&GetBorrowerNotification($BorrId,'POST');
if ($notification eq 'POST')
{
$EmailAddress1 = "";
printf STDERR "POST:Borrower $BorrId Note:$notification Email:$EmailAddress1 \n";
}
if ($notification eq 'ELEC')
{
$EmailAddress1 = 'mailto:' . $EmailAddress1;
printf STDERR "EMAIL:Borrower $BorrId Note:$notification email:$EmailAddress1 \n";
}
In the select.pl you could add the following after the first line (although I haven;t tested this)
$BorrName = "$Style $FirstNames $Surname";
&GetBorrowerNotification ($Borrid, 'POST');
next ITEMID if ($notification ne 'ELEC') ;
In terms of testing I generally comment out the lines that update the database in the script. In this case there is a function called update_database that has all the updates in the retrieve.pl
The easiest thing to do is before this function add the lines
sub update_database
{
return(1);
}
and then add some text onto the end of the original function name e.g.
sub update_database_old
{
The script will then call the new function instead of the one that does the updates to the database so you can run the script over and over again. Just remember to remove the changes afterward.
Thanks
Brian Crampton
Developer, Talis
rec_long_soon _letter and notifications
HI Brian
thanks for this, I've amended the scripts as advised but I still have a problem testing as I was using the copy of prod on MIS and by the time it is copied over to MIS the recall letters have been sent. any ideas?
thanks
Lin
rec_long_soon _letter and notifications
Effectively there are two options:
1) Create some reservations against on loan items on the MIS that meet the requirements
2) Remove the rows from the RECALL_LOAN and LETTER_SNT tables on the MIS for the most recent recalls so they will get picked up again
delete RECALL_LOAN
where LOAN_ID in
(select TRANSACTION_ID from LETTER_SNT
where TYPE=1 and LEVL=0
and DATE_SENT > "Nov 29 2008")
delete LETTER_SNT
where TYPE=1 and LEVL=0
and DATE_SENT > "Nov 29 2008"
You may not pickup the same numbers as before as it is possible that some of the reservations won't be active any more but you should pick some thing up with the script. You may need to go further back with the date depending on the number of recalls that are done daily.
Thanks
Brian Crampton
Developer, Talis
borrower notification res waiting
Hi Brian
I've got the overdues and recalls working now subject to further testing and scheduling with the existing printed and telemessage notices. I'm looking now to set up the res awaiting notices and have modified the format.pl retrieve.pl main.pl and param files but I am stuck with where and how to add to select.pl
can you advise please
many thanks
Lin
borrower notification res_wating_letter
The res_waiting_letter is more straight forward than the recalls letters and overdues.
Whether to produce a letter would be dealt with in the the select function in the select.pl
sub select
{
&GetBorrowerNotification ($BorrId, 'POST');
if ($notification ne 'ELEC') { return 0; }
... as normal
Thanks
Brian Crampton
Developer, Talis
Hi Brian thanks again,
Hi Brian
thanks again, select is now working. It's been interesting and I've learned a bit more about notice production too. Just when you thought it was safe to close this one :) I wonder if you can explain why a Decisions report on reservation circulation notices does not return aby results even though there are types 2 rows in the LETTER_SNT table and Decisions reports ok on Overdues and Recalls.
Regards
Lin
borrower notification and Decisions
No reason springs to mind immediately
Could you let me know the objects used in the results and the conditions used.
Thanks
Brian Crampton
Developer, Talis
borrower notification and Decisions
Hi Brian
In Decisions I'm using the circ universe and circulation letters object, overdues/recalls and date of letter dimensions in the results. I'm not using any query filters
the query returns overdues and recalls but not reservations.
the values in the list for the overdues/recalls dimension include
order, chaser, recall, overdue, open order, reservation.
I took the reservation value to be reservation awaiting collection notices.
I traced a reservation awaiting collection that had a notice generated by running the following on MIS and identified a borrower with a reservation awaiting collection
1> select RESERVATION.BORROWER_ID,BARCODE from BORROWER,RESERVATION,LETTER_SNT
2> where RESERVATION.RESERVATION_ID = LETTER_SNT.TRANSACTION_ID
3> and LETTER_SNT.DATE_SENT >"DEC 14 2009"
4> and BORROWER.BORROWER_ID = RESERVATION.BORROWER_ID
5> go
I found a borrower who had a telemessage generated last night (so that the LETTER_SNT table would not yet have been reset by the telemessage returns script)
"V","2","1","819154189","Mr","Muhammad Abdul","Quddus","01274745534","BFD","Bradford Library","186976621","12/12/2009","Dream on / by Bali Rai","123472"
so I know that the data to populate the Decisions query is in the databases, providing Decisions is using letter_snt and type 2 ???
Cheers
Lin
Reservation letters and Decisions
Lin,
There are few things that are combining to make it a little confusing
The Circulation universe does not contain details about reservations which are held in the Reservation Universe. This is why the object is called "Overdues/recalls". Now you should be only able to see overdues and recalls in the list of values but it is showing all the letter types (even then not all the letter types are in current use). That needs to be corrected.
Another reason for only reporting on overdues and recalls is that both these types of letter are connected to a loan and the TRANSACTION_ID in the LETTER_SNT for the two types is the LOAN_ID. In the Circulation universe the LETTER_SNT table is linked to the LOAN table. This means that a different structure would be needed for reservations as the TRANSACTION_ID is a RESERVATION_ID for reservation letters in LETTER_SNT.
As reservations are dealt with in a separate universe the reservation letters would not be included on the Circulation Universe and there needs to be changes to make this clearer.
In terms of the Reservation Universe the only object is a measure, "Total reservation letters sent" so additional objects would be required to report on date etc.
I am currently testing the new Alto 5.0 universes and I can update the Circulation and Reservations universes for that version.
In the meanwhile it would be possible to get the information out if you are only using those two objects listed above by changing the SQL statement in the Query Panel from
SELECT
substring(dbo_LETTER_TYPE.NAME,1,20),
dbo_LOAN_LETTERS.DATE_SENT
FROM
dbo.TYPE_STATUS dbo_LETTER_TYPE,
dbo.LETTER_SNT dbo_LOAN_LETTERS
WHERE
( dbo_LETTER_TYPE.TYPE_STATUS=dbo_LOAN_LETTERS.TYPE )
AND ( dbo_LETTER_TYPE.SUB_TYPE=28 )
AND ( dbo_LOAN_LETTERS.TYPE IN (0,1) )
to
SELECT
substring(dbo_LETTER_TYPE.NAME,1,20),
dbo_LOAN_LETTERS.DATE_SENT
FROM
dbo.TYPE_STATUS dbo_LETTER_TYPE,
dbo.LETTER_SNT dbo_LOAN_LETTERS
WHERE
( dbo_LETTER_TYPE.TYPE_STATUS=dbo_LOAN_LETTERS.TYPE )
AND ( dbo_LETTER_TYPE.SUB_TYPE=28 )
AND ( dbo_LOAN_LETTERS.TYPE IN (0,1,2) )
All I did was add 2 to the list for dbo_LOAN_LETTERS.TYPE however if you add any other objects outside of the Circulation letters class this won't work
Thanks
Brian Crampton
Developer, Talis
borrower notification and Decisions
Hi Brian
I've done a bit more exploring and I think the answer is that the circ universe doesn't have a link to the reservation letters, only the loan letters. They are in the reservation universe
oh well it kept me entertained for a while. but why is there a reservation value in the circ letters dimension?
Lin
Scheduling email notifications
Hi Brian
can I pick your brains about scheduling, as you'll remember we have telemessages running in Bradford and I would like to schedule the email notices to run before the telemessages. ( email is free!) Can you forsee a problem with scheduling in the following order
1. email overdues, recalls, reservation waiting collections
2. telemessage overdues, recalls, reservation waiting collections
3. telemessage reset
4. email overdues, recalls, reservation waiting collections
5. postal overdues, recalls, reservation waiting collections
email runs first so overrides any borrowers with T or V prefixes
email runs a second time so that failed telemessages get email as a second choice and then postal as a last resort
Can you think of a way of scheduling to avoid running email twice?
Does any one else run all 3 with order of preference; email, telemessage, postal but in a neater way?
many thanks
Lin
scheduling email notifications
What I'm not sure of is why the email would pick the reset overdues etc up if it didn't pick them up in the first email run. The only difference from the Talis Message reset is that the row in the LETTER_SNT table is removed. If the borrower wasn't picked up for email first time around the database would not have been updated to get around why they were not picked up initially e.g. borrower preference or valid email address.
That might not be a problem because of the scripts and code you have set up as I haven't seen the detail.
Using the analysis codes isn't really useful for specifying an ordered preference
Thanks
Brian Crampton
Developer, Talis
scheduling email notifications
Hi Brian
sorry I've been quiet for a while it's a slow job setting all this up!! At least it is for me...
Brian you are right I wasn't thinking too well that day. I'm reverting to plan A which was simply to run the email scripts first, telemessage next and finally printed notices.
I think I'm now ready to go live, I've added the email scripts to the shell script that runs all of the daily notices and reports. Now I'm a bit concerned because although I've tested them on MIS I had to change some of the file paths when I moved them to live and also check and change some of the owner and permissions. I'm trying to think of a way to 'test' them on live and all that I can think of at the moment is to copy the email scripts into a test shell script and do a first run of the email notices scripts and email_post scripts manually.
Does this sound sensible?
Sharon, all I can say at the moment is that it has been hard work. I think most of my problems have been around using the analysis code and the get_borrower_notification perl tool, so if you aren't doing this it might be a bit easier. There's been a lot of donkey work setting up overdues, recalls for each of the 5 loan types and res waiting scripts and testing. I don't think that there is any reset for failed emails I guess you just have to accept that if your job has run and produced an out file then the emails have gone. At least this is the basis that I've been working on.
Thanks for all the help I've had
Lin
scheduling email notifications
It is always a bit nerver racking running for the first time on the live so running sections manually is a sensible approach.
What I've tended to do is comment out the email_post.pl and print lines in the shell script so that the output is produced and then run the email and printing commands manually (or in another script) after checking the output during the day.
Thanks
Brian Crampton
Developer, Talis
Hiya. We are just about to
Hiya. We are just about to look at this for Aberdeenshire as well and we also have TalisMessage, so I was also thinking that I should run it in the order of email, TalisMessage (SMS or Phone) and lastly letters. We can't use the analysis codes as they are used for something else. But if we run the overdue letter to be the input file for the email, then run the email that should mark the database and then if the email fails will it do the equivalent of TM reset (or not) and then at this point I would want it to kick in to TM scripts,then reset and have the letters kick in. It seems terribly convoluted but email and SMS are probably the road we are going to go down. Any thoughts would be welcome! Thanks. Sharon
Borrower notification preferences
There is nothing that resets the database if an email fails. Partly this is becuase the Talis server wouldn't necessarily get this message and then you have the issue of extracting the right details out an error message. In Talis Message this is easy as the Talis Message server sends back a structured file that contains the LOAN_ID (or RESERVATION_ID) so the LETTER_SNT table can be updated.
Since the LOAN_ID wouldn't be in the email you would have to use the item barcode and borrower barcode to get to the LOAN_ID so that would require the error message to include the text of the failed email. Also the text would tend to vary from customer to customer.
There are other approaches that can be taken to using borrower preferences but these would require more changes to the scripts i.e. you could set up code in each script that calculates what the transmission method is. That test might be check the email address, if that fails then do they have a V or T on the telphone number, if that failes then they will be postal notifications. There are still a lot of issues in setting this up and there is always an issue with TM resets as there is no record of a failure in the prod_talis database.
Thanks
Brian Crampton
Developer, Talis
Borrower notification preferences
Hi Brian
I bit the bullet and have run the scripts manually, good job too as there was a typo.
It seems to be running through smoothly, we don't yet have many borrowers who have elected to receive email notices so it's good to be ironing out any wrinkles early on. I have noticed that there are some borrowers who have mailto: in their Alto email addresses, added by staff. the scripts are then adding another mailto: so the email address is appearing in the out file as mailto:mailto:anybody@anywhere.co.uk.
email_post_pl is picking these up and sending them but as there is no report back for failed deliveries, do you know if these emails will fail to be delivered?
Do we need to stop staff adding mailto: when they input email addresses and clean up those already on the system or is there a tweak to the scripts that will deal with this?
nearly there!!
Lin
Adding or not adding mailto: tags
I'm pretty sure it is going to fail with two mailto:tags next to each other although I haven't tested. Regardless it doesn't look good.
You have the local perl tool AdjustMailto on your system (at least on the MIS. I don't think there are on the main server) and that should add or remove the mailto tag.
You have the require statement in the main.pl for the perl tool so the script should know where it is but I could see the actual call of the perl tool.
In the retrieve.pl replace the line
$EmailAddress1 = 'mailto:' . $EmailAddress1;
with
$EmailAddress1 = &AdjustMailto($EmailAddress1,1);
Try this on the MIS and see if that helps and then it can be added to the live server version and the local perl tool added as well. This would have to be done in the relevant versions.
Thanks
Brian Crampton
Developer, Talis
Adding or not adding mailto: tags
Hi Brian and everyone in the thread
Thankyou for all the help, email notices have been running live for almost a month now and seem to be working in the way I expected. It's been a bit of a tortuous job but we got there in the end.
Thanks again
Lin
Email notifications
As someone who has no access to the servers and therefore cannot play around with the scripts, would anyone be willing to share their set up of email notifications as detailed in this thread so that I can talk our IT department into setting this up for us here in Rotherham?
Many thanks
Traci
Email notifications
Hi Traci
I'd like to be able to say that I could help but I think the job is too big for me. Based on my own experience impelemeting this in Bradford there is so much that could be local to your system and ways of working that I think this would be pretty complicated I haven't actually counted the number of hours that I have spent on it but I was working on it on and off over about 4 months. Implementing overdue, res waiting, and a suite of recall notices for the different loan types, there are somewhere in the region of 50+ individual scripts to create, edit, test and schedule etc. There may be others out there with more experience and a clearer head than me who would be less daunted but honestly it has been a marathon!!
good luck and sorry I can't help
Lin
email_post.pl and adjustmailto: case sensitivity
Hi
I've just picked up a little problem with the email notices. About 15% of the borrowers in the Alto database have Mailto: with a capital M prefix in their email addresses. Adjustmailto.pl doesn't recognise this as a valid prefix when looking for the presence of mailto: so it adds another mailto: prefix causing the email to fail. I edited adjustmailto.pl so that it will recognise Mailto: aswell as mailto: but the problem is then with email_post.pl which doesn't recognise Mailto:!!
Is the answer to run a script to update the email address where the prefix is Mailto: just prior to running the email notices scripts each night?
It seems a bit odd to run a script to do an update so that another script can then do a update!!!!
Alternatively is there a version of email_post.pl that will use Mailto: aswell as mailto:
do other sites run such data correction scripts and if so does anyone have one to do this already? or do you rely on staff training?
it all seems to be getting more and more convoluted or have I lost the plot again !!
mmm?
Lin
mailto case sensitivity
Ultimately the best approach is to correct the database itself but the change shouldn't be to just add Mailto: to the perl tool as being a valid value because it isn't as you found further down the line.
The Perl tool needs to correct the value returned. Below is an example of the change. I haven't tested it but it should work.
sub AdjustMailto
{
local($String,$Adjust) = @_;
# Check if the string has mailto: at the beginning
if ((substr($String,0,7)) eq "mailto:" || (substr($String,0,7)) eq "Mailto:")
{
$EmailFlag = 1;
}
else
{
$EmailFlag = 0;
}
# Add or remove the mailto: string
if ($Adjust == 0 && $EmailFlag == 1)
{
# Want to remove mailto: and it is at the beginning of string
#print "STEP A \n";
($adjusted_string) = (substr($String,7,(length($String))));
}
elsif ($Adjust == 1 && $EmailFlag == 0)
{
# Want to add mailto:
# print "STEP B \n";
($adjusted_string) = "mailto:" . $String;
}
else
{
# No change to make
# print "STEP C \n";
if ((substr($String,0,7)) eq "Mailto:")
{
($adjusted_string) = "mailto:" . (substr($String,7,(length($String))));
}
else
{
($adjusted_string) = $String;
}
}
# Return the email address
return($adjusted_string);
}
1;
Brian Crampton
Developer, Talis
Thanks Brian tested on MIS
Thanks Brian
tested on MIS ok so I've applied it to live and done a little test run for ressies awaiting collection
Is there any mileage in using sql scripts to do updates to fix common data entry errors and does anyone have examples that they use?
Lin
new page problem with the email notices out file
Hello Brian
just when you thought it was safe........
I have a problem with the overdue email notices. The out file for the res recalls, underdues, res waiting all have a ? separating the text for each borrower and the emails are sent correctly so that each borrower gets just their text. The out file for the email overdues doesn't have this and email_post.pl sends the whole out file to each borrower in the file. The param files for all the notices have the pagelength and pagination lines remmed out. I am stuck as to where to look to fix this. Can you help please?
thanks
Lin
new page problem
I think that might be related to local changes that were made when the system was first installed to accommodate local requirements but I would have to remind myself because it was a while back (at least in terms of my memory).
I will raise a case in order to track this.
Brian Crampton
Developer, Talis
E-mail
Hiya. We're revisting this again due to budget cuts. I'm wondering if I could run the overdues, followed by the email_post and then drop the letters output file into the talismessage folder to be phoned out and then of course the reset file can be used to generate the remainder of them as letters. My question, is really - can the email letter output be put into the talismessage send folder without formatting or would it be more complicated (and I think it will be!). Or do I just begin the very complex process that Lin's just gone through! Thanks. Sharon
email and telemessage
The letter/email output will be in a letter form. The output for Talis Message requires the data to be in a delimited file with the data elements in a particular format and order.
It would require processing the output file to extract out strings and would also require that the letters contain all the information required for both letters and Talis Message. You may not wish to have the users telephone number in letters. That approach would be more complicated than modifying the scripts.
I think what you describe would not be as complicated as Lin implemented.
1) Run the Talis Message scripts but modify them so that if they have an email address this overrides that they have the T or V flag and the borrower is not processed.
2) Run the "normal" overdues. The Talis Message overdues will have been picked up so the other borrowers with overdues would get picked up and then the output can be processed by email_post.pl.
Of course there may be more fine detail that makes it more complicated.
Thanks
Brian Crampton
Developer, Talis
Thanks Brian. I'll try it
Thanks Brian. I'll try it out on our MIS and see how I get on. Best wishes, Sharon
E-mail notification
Hi Brian. Have tested the email setup internally and it worked fine. Thanks for the pointer on using TalisMessage. We can now simply put a V (for Voicemail) in front of the phone number, T (for Text Message) in front of the phonenumber or an X for no phonecall (if they wish an email or letter). It will be a lot of work for staff but worth it in the end I suspect. TalisMessage will run before the emails and reset those that don't get a phonecall or text. Then the overdues will run, followed by the email_post and then the remainder printed. I've tested it and fingers crossed, it seems to be working!! Thanks. Sharon