Skip to content

Instantly share code, notes, and snippets.

@keirbowden
Created March 15, 2014 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save keirbowden/9566240 to your computer and use it in GitHub Desktop.
Save keirbowden/9566240 to your computer and use it in GitHub Desktop.
Visualforce controller with a JavaScript remoting method to retrieve a matching record after scanning a barcode.
public with sharing class BarcodeSF1Ctrl
{
@RemoteAction
public static String getRecordFromBarcode(String bcStr)
{
String result;
List<String> eles=bcStr.split(':');
String code=eles[1].trim();
List<Account> accs=[select id, Barcode__c from Account where Barcode__c=:code];
if (0!=accs.size())
{
result=accs[0].id;
}
else
{
result='Error: no record matching ' + code + ' found';
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment