(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.data-privacy-src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-PF5R8F7');

Knowledge Base

Database Builder with Postback URL

About DBB + Postback

Note: This feature has been replaced with the curated Table Builder service type which significantly improves the functionality. 

First, constructing your DBB Postback doesn’t require any coding. Easily, just copy and paste based on the instructions below.

The key benefit with DBB Postback is directly updating a validation database stored in our servers in real-time. Thus, you don’t have to export scan records and create a new, updated CSV file to upload to that database. Learn more about creating and managing a barcode database here.

A validation database is a table of barcode values and associated data stored on CodeREADr’s servers for use with your validation Service types. After each scan, you can present the associated data as a ‘response’ to the user if the barcode value exists in that database.

Normally, if the barcode value doesn’t exist in the database, the user will get an Invalid response after scanning that value. However, with DBB Postback, you can enable users to add that value to the database along with associated data (text, photos, etc.). Then, allow them to edit data associated with values already existing in the database.

Also, we save scan records on our server. Then, from the Scans page, you can filter, share, export, or insert it into third-party databases.

DBB Postback only works when the user has Internet connectivity. Also, use it only when you need to add or edit the data associated with the scanned barcode value. If you want to add values to a validation database, use Pattern Validation, which can work online or offline. Learn more about using Validation Pattern Matching here.

Primary Use Cases

  1. One Service to build a database for a different Service: The authorized App users for Service A post the DBB Scan Records to the DBB Destination Database. Also, they build the database to use with Service B. This will be a totally separate Service without the ability to add or edit values. For example, Service A may provision IDs, vouchers, or assets to the destination database. However, Service B simply validates if the value is in the database and checks for duplicate scans. Also, you can use this service for access control, attendance, voucher redemption, asset tagging, and more.
  2. One Service to build and continuously update the same database: With the add + update use case, app users can post DBB Scan Records to the DBB Destination Database. Also, they can update the DBB Response after any scan. It’s popular for asset tracking with status updates (location, condition, disposition); student/member/employee record updates; and inventory management with location and quantity updates.

Definition of Options

  1.  DBB Scan Record: This is the DBB Value and the DBB Response. First, the DBB Value is scanned or manually entered barcode value. Second, the DBB Response is the stored result when the app user answers questions. Depending on your URL, those answers either replace existing data in the DBB Destination Database or it will add those if not already there.
  2. DBB Destination Database: This is the validation database, which stores the DBB Values and the DBB Responses. It can be a validation database associated with the Service. Also, it can be a database associated with a totally different Service. The latter option can be valuable. For example, you use one service to provision values to a database of IDs, assets, etc. However, you use a different service is to check if those values are in the database before the disposition process.

Instructions

First, create a destination database. Then, copy the Database ID.

Shared Database

Second, create a validation service.

Validate scans with a database

Then, you can add questions. However, you must have them appear after a user submits a scan.

Third, retrieve your API key from your account details page.

Insert API Key

To obtain your API key, you will need to have a paid account.

Next, create your Postback URL. This is where you use the database ID and API Key. First, you replace ‘DB_ID’ with the destination database ID. Then, replace ‘API_KEY’ with your API Key. Edit this URL (copy & paste into a text editor, e.g. Word, Notepad, etc. with no spaces):

https://api.codereadr.com/pb/dbb-postback.php?database_id=DB_ID&api_key=API_KEY

Finally, on the Advanced tab, insert your Postback URL into the Postback section. Check the default options.

Enter post back URL

To format the data as structured data, check ‘Alter Response Value’. Then, copy and paste the following:

  • Alter Response Pattern: ^([\s\S]*?)$

This Alter Response Replacement script works for older versions of Android OS (4.1 and higher). However, you need iOS 10.0 or higher even though the app supports lower iOS versions.

Alter Response Pattern

There are three optional variables within that document:

  • showLabels = true (or false)
  • defaultResponse = “Custom message for empty responses go here.”
  • defaultOrder = [enter question IDs separated by a comma]

Postback Construction Options

Example URLs

  • Add + Edit (adds values and answers if not already in the destination database and allows the editing of prior answers): https://api.codereadr.com/pb/dbb-postback.php?database_id=DB_ID&api_key=API_KEY&require_answer=false
  • Edit Only (only allows the editing of prior answers already in the destination database): https://api.codereadr.com/pb/dbb-postback.php?database_id=DB_ID&api_key=API_KEY&require_status=valid

The most common mistake is including a space in the URL or missing part of the text (a ‘variable’) which you need to append to the URL. Thus, check your URL in a text editor, such as Notepad if you have any trouble.

Require Answer

The optional variable “&require_answer=false” will give an Invalid response to the app user. However, it will add the DBB Scan Record to the DBB Destination database once submitted. The variable &require_answer=true will give the app user a Valid response since the value needs to already be in the DBB Destination database. The app users will see the existing associated data. Also, they can edit that data by entering new data if they answer the questions.

Require Valid Response

This optional variable “&require_status=valid” will only add DBB Scan Record if the scanned value is already in the DBB Destination Database. If you use this variable, app users will not be able to add new values to a DBB Destination Database.

Labeling Response Text

This optional variable “&transfer_label=YOUR_LABEL_TEXT” presents your original response text (i.e. column 2 of your validation database) for each value to the app user when that value is scanned. For example, this will show the description of the asset after a scan along with DBB Responses.

Export Template Instructions

On the Scans page choose “Create a Template.”

  1. Let’s assume you had three questions labeled as the following:
    Name
    Address
    Company
  2. Drag (or click +) ‘Result’ from the ‘Static’ choices on the left to the ‘Columns’ for the template on the right.
  3. Then click the Result field’s pencil icon and choose Custom to modify the column using a pattern and replacement.
  4. You will edit this regex and then enter it in the Pattern field. A good practice is to paste it in a text editor (e.g. Notepad or similar) and be sure there are no spaces.

5. You will enter this in the Replacement field:
$1

6. Use the clone icon next to the pencil to duplicate the Result column for as many fields as you want to collect. For this example, you would clone until I had 3 Result fields to match these 3 questions. You would also rename the header to Name, Address and Company.

7. For each Result field, swap out QUESTION_LABEL with the one you want to be in that column (e.g. Name, Address or Company). For each QUESTION_TYPE, replace with the label found in the raw data, e.g. “text”

For our example, our final patterns should be:

When you export or download your scan records be sure to select this template. Please email support@CodeREADr.com if you need assistance.