Created
March 15, 2014 12:19
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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