[Koha] Updating 856 Field

Graham, Stephen s.graham4 at herts.ac.uk
Wed Jun 22 22:29:19 NZST 2016


Hi All - we want to change the 856 field in over 18,000 records. The actual change itself is easy - simply URL encoding the existing URL, and then prefixing it with another value. I am thinking of scripting this job.


1.       Identity and retrieve the biblio IDs from a SQL query

2.       Iterate over the IDs and use C4::Biblio:: GetMarcBiblio to retrieve the MARC record

3.       Grab the 856, subfield u value and make the change

4.       Use C4::Biblio:: ModBiblio to update the record in Koha

The actual relevant code would look something like (this is inside a loop which is iterating over the array of BIB IDs):

my $marc_record = GetMarcBiblio($id);

if ($marc_record) {
my $url = $marc_record->field('856')->subfield('u');
                my $field_856 = $marc_record->field('856');
                my $encodedURL = &encodeURL($url);
                my $wURL = $eblPrefix . $encodedURL;
                $field_856->update( u => $wURL);
                my $updated = ModBiblio($marc_record,$id,'');
}

I've test this on 10 records and it seems to work OK. My main question is, are there any "gotchas" doing it this way - anything I need to look out for/anything I've missed?

I'm not explicitly indicating any encoding format - I'm assuming that what goes back into Koha , will be the same as what I took out (apart from the URL)  - with all the encoding the same. Is that assumption correct?

Is it OK to make this change to 18K in one go?

Before I run the script I'm make a dump of the biblioitems table (which I think is the only table effected by this update), and the script dumps out the BIB IDs and the MARC records to file for reference.

How does this sound/look?

Cheers, Stephen

Stephen Graham
Library Technology Consultant
Academic Resources
Library and Computing Services
University of Hertfordshire
Hatfield  AL10 9AB
UK
Tel. 01707 286111 Ext: 77751
Email s.graham4 at herts.ac.uk



More information about the Koha mailing list