Multiple barcode scanning in Now Mobile, not sending to WriteBackAction (Utah)

Paul Hegel
Mega Guru

I’ve developed several different Mobile App Builder Functions to scan barcodes.  I’ve successfully developed a function to consume inventory from the alm_consumable table. Using a single input of type Barcode and that is working.

Example Code in WriteBackFunction:

(function WriteBackAction(parm_input, parm_variable, actionResult) {

    // get input values

    gs.info('Consume Inventory Function: parm_input = ' + JSON.stringify(parm_input, null, '\t'));

 

})(parm_input, parm_variable, actionResult);

 

This is the output of the function in the system logs:

Consume Inventory Function: parm_input = {
"stockroom": "32c1ffd51bf17110a95611f8bc4bcb72",
"quantity": "1",
"site_location": "dc8f4ef4db6f8c50f76bda75ca961970",
"barcode": "CPM0003194"
}

The first method that I tried:

Configuring my Consume Multiple Barcodes function I used this reference: Configure input form screens with grouped scan barcode inputs (servicenow.com)

My configuration:

PaulHegel_0-1708713483563.png

 

 

Input form section:

PaulHegel_1-1708713483566.png

 

PaulHegel_2-1708713483567.png

 

Result

  1. that the barcode scanning works and will scan multiples barcodes:PaulHegel_3-1708713483573.png

     

    PaulHegel_4-1708713483575.png

     

    PaulHegel_5-1708713483576.png

     

  2. It appears to carry values back to main form:
  3. However, the submit doesn’t send all the input values.

 

Using this same code in my Consume Multiple Function:

(function WriteBackAction(parm_input, parm_variable, actionResult) {

    // get input values

    gs.info('Consume Multiple Function: parm_input = ' + JSON.stringify(parm_input, null, '\t'));

 

})(parm_input, parm_variable, actionResult);

 

I get this which is missing barcodes:

Consume Multiple Function: parm_input = {
"quantity": "1",
"stockroom": "3beabf471bbbf110a95611f8bc4bcb70"
}

Based on the documentation I’d expect it to look like this:

Consume Multiple Function: parm_input = {
"barcodes": {"inland_barcode": ["CPM0003647", "CPM0003647"]},
"quantity": "1",
"stockroom": "3beabf471bbbf110a95611f8bc4bcb70"
}

Then second I tried this method:

 Configure a grouped input for multiple scans (servicenow.com)

PaulHegel_6-1708715353275.png

 

But the barcode inputs did not show on  the Input Form Screen.  But the input shows up after I click submit.  The functionality appears to work ,  and it has the same output to the log files.

1 ACCEPTED SOLUTION

Paul Hegel
Mega Guru

My solution is to move away from using the Mobile version for multiple barcodes scanning and move to using portal pages/widgets and the cabrillo.getBarcode() methods and GitHub Example: K17-Service-Portal-And-Mobile/Lab 2/K17 Barcode Scanner.

I expanded on this concept, but the nice part is that you have control of scanning multiples using your widget code.

This only works in ServiceNow native mobile applications.  You can use the cabrillo.isNative to see if the page is just that a ServiceNow Mobile application (Now Agent, Now Mobile).

 

I added an array to the client side that captures multiple.  Once I've completed my code I'll try to put my example on GitHub.  

 

Note that a user could have a regular barcodes scanner which acts as keyboard entry, or they might only have the camera on their phone.  Cabrillo uses the camera on your phone to scan barcodes.

 

Thanks,

Paul

View solution in original post

6 REPLIES 6

Sumanth16
Kilo Patron

Hi @Paul Hegel ,

 

Can you refer to the below thread:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0853143

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

 

 

 

@Sumanth16,, If you read through my configurations you will notice that I've set that MaxEntries value to 100.

Thanks for the research though!

-Paul

Paul Hegel
Mega Guru

My solution is to move away from using the Mobile version for multiple barcodes scanning and move to using portal pages/widgets and the cabrillo.getBarcode() methods and GitHub Example: K17-Service-Portal-And-Mobile/Lab 2/K17 Barcode Scanner.

I expanded on this concept, but the nice part is that you have control of scanning multiples using your widget code.

This only works in ServiceNow native mobile applications.  You can use the cabrillo.isNative to see if the page is just that a ServiceNow Mobile application (Now Agent, Now Mobile).

 

I added an array to the client side that captures multiple.  Once I've completed my code I'll try to put my example on GitHub.  

 

Note that a user could have a regular barcodes scanner which acts as keyboard entry, or they might only have the camera on their phone.  Cabrillo uses the camera on your phone to scan barcodes.

 

Thanks,

Paul

Hi Paul,

Does the portal.widget concept and the cabrillo API gel with users using the agent app? As in, can you have an internal window in the agent app that just forwards the users to a portal page for certain actions?
I'm trying to find a solution to an issue I've got with barcode scanning here https://www.servicenow.com/community/mobile-apps-platform-forum/can-a-list-of-scanned-barcodes-be-ed...

I'm exploring the actionResult object now, but there's very little documentation on it other than actionResult.setRedirectionInfo and actionResult.addAttachment

I'm trying to figure out whether I can either edit the list of results of a barcode scan after my execution script runs, or forward the user onto another scanning page within the app and pass in the list of failed results. This portal and API option sounds curious, though probably a lot of extra work.