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/