Pulsar has many useful tools that can be used in the field to perform key day to day operations. One such new feature is the barcode/QR code scanner. This blog post discusses a particular use case to explain how the feature can be used.

Imagine a situation where a company lends physical assets to stores. In this case, the asset is a refrigerator. The field rep walks into the store and they need to report that the asset is still in the store. Instead of manually searching for the refrigerator ID, they would use the iPhone/iPad camera to read the serial number of the refrigerator and automatically log a completed Task to note that it is still there.

How does it work behind the scenes?

1. First enable the Code Scanner Icon on a record. This Pulsar Setting enables the icon to show up on the Opportunity page toolbar.

PulsarSetting Name: Enable Barcode Scanner
Key: pulsar.layout.enableBarcodeScanner
Value: Opportunity:Default

2. Set the button name on the scan screen to make sure it makes logical sense to the use case.

PulsarSetting Name: Barcode Scan – Opportunity – Next Button Name
Key: pulsar.BarcodeScanNextButtonName.Opportunity
Value: Log Event

3. Now tell the button action what to do with the recently scanned code. For those of you already familiar with PSL, this is pretty straightforward syntax.

PulsarSetting Name: onBarcodeScan – Opportunity
Key: pulsar.onBarcodeScanAction.Opportunity
Value:
DEFAULT{
Action=SetVar;
VarName=ScanCode;
VarValue=@@CurrentScanCode;
|
Action=SetVar;
VarName=UserId;
VarValue=@@CurrentUserId;
|
Action=SetVar;
VarName=CurrentDate;
VarValue=@@Today;
|
Action=SqlQuery;
QueryString=select (CASE WHEN length(‘%%ScanCode%%’) = 0 THEN 1 ELSE 0 END) as emptyScanCode;
QueryReturnFields=emptyScanCode;
QueryTest=%%emptyScanCode%%=1;
QueryTestTrue=BARCODE_SCANNER_ERROR;
|
Action=SqlQuery;
QueryString=select Id from Store_Asset__c where Scan_Code__c = ‘%%ScanCode%%’ LIMIT 1;
QueryReturnFields=@@QueryCount, Id AS AssetId;
QueryTest=%%QueryCount%%<=0;
QueryTestTrue=ASSET_NOT_FOUND;
|
Action=CreateAndMapFields;
ObjectType=Task;
ActionShouldComplete=TRUE;
ActionShouldDisplay=FALSE;
OwnerId=%%UserId%%;
WhatId=%%AssetId%%;
Status="Completed";
Subject="Post Call Auto Create";
ActivityDate=%%CurrentDate%%;
|
Action=Alert;
Message="Successfully logged the asset";
AlertType=DismissCurrentWindow;
}

ASSET_NOT_FOUND{
Action=Alert;
Message=No Asset matching %%ScanCode%% is found in the database;
}

BARCODE_SCANNER_ERROR{
Action=Alert;
Message=Please point the camera at the code and wait for the scanner to display the number;
}

SUCCESS{}

Here is the series of screenshots to explain what we are doing:

1. You see the option to launch the code scanner

OppDetalScanCode

2. The scanner grabs the code

ReadCode

3. Clicking on ‘Log Event’ logs the event against the Store Asset custom object

LogEvent

4. Now make sure the event is logged against the Store Asset

EventCreated

Hope you find this useful and let us know if you have any questions around your particular use case!