Lookups Using Scanalyzer

This demo shows how Scanalyzer can be used to verify that an item exists in a list.  You may need to verify that students are eligible to attend a school function or that employees or visitors have access to a restricted area or resource, so we've done some of the legwork for you and created this simple example.


QUICK CONFIGURATION CODE

PRIVACY

This Code
INSTANTLY

Sends
BARCODE

To
SCANALYZER
GOOGLE DOCS
THE PUBLIC INTERNET

Lookup Demo

Before you scan this Quick Configuration Code to get started, please note the accompanying privacy advisor.  Now scan a few barcodes.  If you scan an item that's already in the list, you'll be presented with a green screen, otherwise it'll be red.

We've also included code to add new items to the list, so if you scan a new item twice you can see the change.

Instructions that walk you through how to set this up follow.  Enjoy!

Lookup Tutorial


https://docs.google.com/a/mcdanielar.com/spreadsheet/ccc?
key=0AmE18Htty58LdHg1azVMMWtlWTRoZEtySjhpMTFST2c&hl=en_US#gid=2

    • We used a Google Site for our example, so that's where we made the script...
function doGet(e)
{  
  
  //Initialize the app...
  var app = UiApp.createApplication();
  var vPanel = app.createVerticalPanel();
    
  //Create a welcome message and data labels 
  var welcomeLabel = app.createLabel("You sent:").setStyleAttribute("fontSize","36px").setStyleAttribute("color","white");  
  var dataLabel = app.createLabel(e.parameter.data).setStyleAttribute("fontSize","24px");
  
  //Add the labels to the vPanel
  vPanel.add(welcomeLabel);  
  vPanel.add(dataLabel);
  
  //Add the vPanel to the App
  app.add(vPanel);
  
  //Open the spreadsheet by its key value...
  var ss = SpreadsheetApp.openById("0AmE18Htty58LdHg1azVMMWtlWTRoZEtySjhpMTFST2c");//key from url
  SpreadsheetApp.setActiveSpreadsheet(ss);
  var mysheet = ss.getSheetByName("Simple List");
  
      
  //Search for the scanned item
  var myrange = mysheet.getRange("A1:A");  //Range to be searched
  var myvalues = myrange.getValues(); // retrieve all at once
    
  var found = false;
  for (var i = 0; i < myvalues.length; i++)
  {
    if(myvalues[i][0] == e.parameter.data)
    {
      found = true;
      break;
    }
  }
  if (found)
  {
    welcomeLabel.setText("Item Found");
    app.setStyleAttribute("background","green");
  }
  else
  {
    welcomeLabel.setText("Item Not Found");                     
    app.setStyleAttribute("background", "red");
     
    //Insert a new row at the beginning of the spreadsheet.
    mysheet.insertRowsBefore(1,1);
    //Write the barcode to the list.
    mysheet.getRange(1, 1, 1, 1).setValue(e.parameter.data);
   } 
  return app;  

    • On the Share menu, Publish the Script as a Service and grab the URL for use in your configuration code.
    • You'll need to add &data= to the end of the URL, and then tack on the Scanalyzer tags of your choosing.  Note: We're using %09 for the tab character.

  • Configure Scanalyzer Pro with your automation string.  You can cut and paste ours if you want to test it out:
https://sites.google.com/a/macros/mcdanielar.com/exec?service=AKfycbzl0iAeB3nhOW7AlBS7pSBqZ4Nwokrwi3ZVK9hn&data=<barcode>