Skip to content

Commit

Permalink
Tmp v12 (#5)
Browse files Browse the repository at this point in the history
* v12 enhancements

* Update README.md

* Update README.md
  • Loading branch information
suranofsky authored Jun 6, 2020
1 parent c75341f commit 1a8025f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
34 changes: 25 additions & 9 deletions Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function startLookup(form) {


var startingRow = form.rowNumber;
var selectFirstRecord = form.selectFirstRecord;

//SETUP SHEETS/TABS/RANGES TO READ FROM/WRITE TO
var settingsTabName = form.tabSelection;
Expand All @@ -71,6 +72,9 @@ function startLookup(form) {
checkLocalCode = checkLocalHoldings.substring(x+1,checkLocalHoldings.length);
}

//ADD THE ABILITY TO SEARCH BY ISSN
//SEARCH TYPE WILL BE ISBN OR ISSN
var searchType = dataSheet.getRange(1, 1).getValue().trim();

//FOR EACH ITEM TO BE LOOKED UP IN THE DATA SPREADSHEET:
var lastRow = dataSheet.getLastRow();
Expand All @@ -87,9 +91,17 @@ function startLookup(form) {
//VALUE IN THE LCCN COL.
//IF THE ROW CONTAINS NEITHER IT MOVES TO THE NEXT ROW
if (!isbnCell.isBlank()) {
//isbn could hold an issn or isbn depending on the column is labeled
var isbn = isbnCell.getValue();
if (isbn.length < 10) isbn = pad(10,isbn,0);
searchCriteria = "srw.bn=" + "%22" + isbn + "%22";
if (searchType == "ISBN") {
//ISBN SEARCH
if (isbn.length < 10) isbn = pad(10,isbn,0);
searchCriteria = "srw.bn=" + "%22" + isbn + "%22";
}
else {
//ISSN SEARCH
searchCriteria = "srw.in=" + "%22" + isbn + "%22";
}
}
else if (!lccnCell.isBlank()) {
searchCriteria = "srw.dn=" + "%22" + lccnCell.getValue() + "%22";
Expand Down Expand Up @@ -223,18 +235,19 @@ function startLookup(form) {
//TO THE NEXT LOOKUP
if (matchedTheCriteria == 0) {
found = true;
matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,x,dataSheet);
matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,x,dataSheet,0);
break;
}

}
//ADDED 8/22/2019
//IF FOUND == FALSE & THE SEARCH FOUND AT LEAST ONE RECORD - USE THE TOP RECORD
//IT WILL BE THE ONE WITH THE LARGEST NUMBER OF HOLDINGS
if (listOfRecords.length > 0 && found == false) {
//6-6-20 MAKING THIS CONFIGURABLE WITH A CHECKBOX
if (listOfRecords.length > 0 && found == false && selectFirstRecord == "true") {
var dataFields = listOfRecords[0].getChild("recordData",nsp).getChild("record",slimNsp).getChildren("datafield",slimNsp);
var controlFields = listOfRecords[0].getChild("recordData",nsp).getChild("record",slimNsp).getChildren("controlfield",slimNsp);
matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,x,dataSheet);
matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,x,dataSheet,0);
}

}
Expand All @@ -250,7 +263,7 @@ function startLookup(form) {



function matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,rowNumber,dataSheet) {
function matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,rowNumber,dataSheet,recordCount) {

var ui = SpreadsheetApp.getUi();
var colors = new Array(1);
Expand Down Expand Up @@ -297,6 +310,9 @@ function startLookup(form) {
//WRITE RESULTS
var oneRowDataRange = dataSheet.getRange(rowNumber+1,outputColStart,1,outputRange.getNumRows());
oneRowDataRange.setValues(colors);
//6-6-20 - IF THERE WAS MORE THAN ONE LOCAL RECORD FOUND
//BOLD THE ROW
if (recordCount > 1) oneRowDataRange.setFontWeight("bold")
}


Expand Down Expand Up @@ -346,14 +362,14 @@ function startLookup(form) {
var slimNsp = XmlService.getNamespace('http://www.loc.gov/MARC21/slim');

var root = document.getRootElement();
var test = root.getChild("numberOfRecords",nsp).getValue();
if (test == "1") {
var recordCount = root.getChild("numberOfRecords",nsp).getValue();
if (recordCount > 0) {
//FOUND A LOCAL RECORD, WRITE RESULTS TO THE SPREADSHEET
var records = root.getChild("records",nsp);
var listOfRecords = records.getChildren();
var dataFields = listOfRecords[0].getChild("recordData",nsp).getChild("record",slimNsp).getChildren("datafield",slimNsp);
var controlFields = listOfRecords[0].getChild("recordData",nsp).getChild("record",slimNsp).getChildren("controlfield",slimNsp);
matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,x,dataSheet);
matchFoundWriteResults(outputRange,dataFields,controlFields,dataRange,x,dataSheet,recordCount);
return true;
}
return false;
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ I collaborated on this project with Lehigh's Cataloging/Metadata Librarian, Lisa
<br><br>
We co-presented a session about this project to the ALA Technical Services Workflow Efficiency Interest group during the American Library Association's 2019 annual conference. You can view our slides here: https://connect.ala.org/HigherLogic/System/DownloadDocumentFile.ashx?DocumentFileKey=3a69473d-a4a3-4781-a546-72b394ef3886
<br><br>
We are co-authoring an article about the project which will be published in the November 2019 issue of the code4lib journal.
We co-authored this article about the project in the November 2019 issue of the code4lib journal:<br>
https://journal.code4lib.org/articles/14813
<br><br>
This add-on is publicly available using the “Add-ons > Get add-ons” menu in any Google Sheet. A search for MARC will show the add-on.
<br><br>
Expand All @@ -13,6 +14,14 @@ https://gsuite.google.com/marketplace/app/matchmarc/903511321480


# Versions

### 6-6-2020
### Version 12
## New Features and Fixes
1) If it finds duplicate local holdings, it will select one and bold the row so you know it found a duplicate
2) If no match is found, it will select the top match (with the most holdings) only if you check the box: Select first record when no match?
3) New ISSN Search: If you label row one, column one "ISBN" it will search by ISBN. If you label row one, column one "ISSN" it will search by ISSN

### 2-7-2020
### Version 11
## New Features:
Expand Down
12 changes: 10 additions & 2 deletions sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
</div>
<br>

<span style="color:white"><b>Select first record when no match?</b></span>
<br>
<div class="block form-group">
<input type="checkbox" id="selectFirstRecord" name="selectFirstRecord" value="true">
</div>
<br>


<span style="color:white"><b>Start search at row#</b></span>
<br>
<div class="block form-group">
Expand Down Expand Up @@ -91,9 +99,9 @@


<br>
<span style="color:white"><b>v. 11</b></span>
<span style="color:white"><b>v. 12</b></span>
<br>
<span style="color:white"><b><a style="color:white" href="https://github.com/suranofsky/tech-services-g-sheets-addon/blob/master/README.md#Versions" target="new">See details about v. 11 in github</a></b></span>
<span style="color:white"><b><a style="color:white" href="https://github.com/suranofsky/tech-services-g-sheets-addon/blob/master/README.md#Versions" target="new">See details about v. 12 in github</a></b></span>
</div>


Expand Down

0 comments on commit 1a8025f

Please sign in to comment.