Barcodes, UI Actions, Record Producers, and Mobile - Oh my!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2018 01:38 PM
Once again, I find myself doing some custom scripting that flies way outside the norm of what ServiceNow expects you to do. I am trying to allow mobile Field Services users to scan barcodes on a record producer that was triggered by a mobile UI action. The UI action also passes in variables from the work order task to the record producer via the URL parameters.
- User views the work order task on their phone in the native app.
- From the main form of the task, not the detail screen that precedes it, the user touches the actions ellipsis icon and then touches the UI action to trigger the record producer.
- The record producer opens up, retrieves the variables from the URL via client script, and displays the barcode enabled string fields.
However, when the record producer is triggered from the UI action, the barcode fields do not display their icons that open the camera to capture the barcode. If the user opens the record producer from the catalog, the icons are displayed, but then the task details are not passed to the record producer.
I know I can have the user enter their task number in the record producer and populate the form that way. I'm trying to solve the barcode scanning problem and make it easier on the field user to access the form.
This is what one of the record producer fields looks like when triggered from a UI action.
This is the same field after opening the record producer from the catalog.
I've tried all the ways of opening the record producer that I can think of. This is my current UI action script.
var params = 'sysparm_cmdb_ci=' + current.parent.cmdb_ci.sys_id + '&sysparm_task_number='
+ current.sys_id + '&sysparm_ci_model=' +
current.parent.cmdb_ci.model_id.getDisplayValue();
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=46c6894adb069b002be712261b961986';
action.setRedirectURL(url + '&' + params);
Has anyone else run into this obstacle and fixed it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2018 11:20 AM
I do have a ticket open with HI and got a response that shows the dev who worked on the previously encountered problem didn't dig deep enough to troubleshoot correctly, or that the functionality changed after the PRB was logged. He basically stated it wasn't possible to use the barcode attribute on variables in the catalog. That statement isn't true, based on what I've seen. Below is the majority of what I researched this morning.
I've dug quite a bit deeper on this issue with a co-worker and learned several things. First, the barcode attribute does work on string fields on record producers, but only when opened from the catalog directly. With one exception that I'll get to shortly. Second, the URL produced by the UI action is very different from the URL produced by the mobile app opening the record producer from the catalog. The URL produced by the app is one of the worst documented features of the platform. Below are links to the only documentation about the way that mobile navigator modules work - and by extension, how mobile UI actions can construct URLs to open records.
This is the official documentation about how to configure a mobile navigator module. It contains a few sentences to explain syntax, but doesn't provide the actual info you need to really know what to do. Scroll down to step 8 and read the part about the path field.
Configure the mobile application navigator
With more digging, I found this community post that explains how the first version of the mobile UI worked. Unsurprisingly, the information is not in the Jakarta documentation. This post contains a table that lists specific examples about how to construct the mobile modules. There are differences in the code that's used in Jakarta. One example is catalog/{catalog_sys_id}/category/{category_sys_id}/item/{item_sys_id}, which is how you open a catalog item directly. The comments on these posts contain several updates like that one.
Create URLs in the ServiceNow Mobile UI to Modules, Favorites, & UI actions
Here is another post specifically about mobile URL structure.
Navigating the ServiceNow Mobile UI
For good measure, here's another post about mobile modules.
Mobile app navigator module parameters
Using info from the posts above, we were able to modify a mobile UI action to trigger a record producer and have it display the barcode icon necessary for triggering the camera. However, using the method listed below, we ended up with a record producer that displays the shopping cart icon in the top right corner of the phone's screen and the add to card button on the bottom of the screen. Both elements are undesirable for our purpose.
Here is the syntax to open a record producer from a UI action: catalog/catalog_sysID/category/category_sysID/item/sysID of the producer
Which results in:
catalog/e0d08b13c3330100c8b837659bba8fb4/category/e15706fc0a0a0aa7007fc21e1ab70c2f/item/a4210c1cdb1adf008b61ae441b96191e
That path will result in the screenshot below.
After a bit more digging, I finally found what I was looking for.
catalog/producer/sys_id of catalog/sys_id of category/sys_id of record producer
This will open the record producer without the shopping cart and add to cart button.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2018 04:45 PM
Now that is impressive. Wish you could mark your own question answered. How did you come across the producer url?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 02:47 PM
Lots of searching the Community combined with trial and error. I started on this path while trying to solve the barcode icon problem, but I ended up with another. I was using the UI action to pass variables to the record producer as URL parameters. Now that I'm triggering the record producer differently, the traditional parameter passing method doesn't work because the mobile app's URLs are totally different.
After talking with HI and the dev team about it, they confirmed that there is no replacement parameter passing method....so we came up with our own method. We created an event, passed the task's sys_id and user's sys_id in as parameters, then pulled them back out in a AJAX query that passed the rest of the info we needed to the record producer in the mobile app.