In a recent blog post, we described the cataloging enhancements made to the BIB APIs. These enhancements include:
- The ability to validate and run normalizations on added/updated records
- Linking/unlinking a local BIB to a network zone record
- Cataloger level, stale version check to ensure that records are not correctly overwritten
- Warnings and override when deleting a BIB record
With these enhancements, it's easy to build a supplemental or quick catalog form. In this blog post, we’ll highlight how to use some of the new features in the world’s simplest cataloging tool.
We’ll be using the Update BIB API and include the querystring parameters which trigger the new features:
We have a small Node.js application running the Express web framework. We’ve built a simple form which displays a BIB record’s title and author. When the user enters an MMS_ID and clicks the "Retrieve BIB" button, we retrieve the brief view of the BIB record and populate the author and title fields with the data returned from the API.
To trigger the validation, we can try to update the BIB record without a title. The validation routine specifies that the title field is required, so by providing the validate=true parameter we should receive an error when attempting to update the BIB.
The form submits a simple JSON object to the server. The server retrieves the full MARC XML record from Alma and uses the XPath and DOMParser libraries to update the relevant field (245 in this case). We then serialize the XML and send it back to the server using the PUT BIB API as shown above.
The server responds with a HTTP 400 status code and we extract the error message from the error object returned in the body of the response. We can then display the error message to the user which includes the specific validation rule that failed, in this case a missing 245 field.
We’ve created a simple normalization rule which adds a local field indicating that the record was updated using the quick catalog form.
rule "Add field 900 when updated by the cataloging form" when (TRUE) then addField "900.a.Updated by the cataloging form" end
We add the ID of the normalization process we wish to run to the querystring of the update BIB API request (see the blog post referenced above for more information on how to retrieve the ID of the normalization process). When the BIB is successfully updated the normalization process is applied and the resulting BIB has the additional field.
In addition, we receive a list of warnings in the response from the update BIB API and can choose to display those warnings to the user.
Those institutions that have implemented cataloging privileges in Alma can leverage them further with the BIB APIs. Since our simple cataloging form is open to the public to update BIB records, we want to specify a low cataloger level so that it can be locked if touched by a professional. To do that we pass a cataloger_level parameter of 00 in the querystring on the update BIB request. So now if we try to update a BIB that has cataloging level higher than 00 we receive an error message and the BIB is not updated.
This simple example shows off some of the new features of the BIB APIs. The code for this sample is available in this repository in Github.