D365: BarTender and label integration using REST API

Do you feel that the of printing labels in Dynamics 365 is a bit difficult? The options we have in standard D365 is to learn Wave label printing. Or you can look into ISV’s as ISV Docentric.

Labeling connects the transactional world with the physical world. We meet customer labels requirements for identifying products, pricing labels, locations, receiving labels, shipping labels, units, boxes, pallets/license plates. In addition to just labeling, there are also the requirements for RFID marking products, and some cases to print out plastic badges or tickets. The possibilities are enormous for automating and improving data quality and process automation.

From my personal experience I have preferred the BarTender solution from Seagull Scientific, and they have now also launched a cloud edition of their labeling system. In Wave 2020 Wave 1, there was in the roadmap an integration to BarTender, but this was moved to a future release. Since then, it has been silent. In short, I have not found a good BarTender integration for Dynamics 365.

So, I decided to just create a new one . But this time using a REST based cloud-integration, that could be generic, and that could also be used for all kinds of integrations. My first step was to deeply understand how such a integration should be working. Then I found the following video on how to set it up by accessing a web service where I just had to post a JSON towards a URL. I will try to explain how I did this in Dynamics 365, and exemplifying it by creating an customer address label.

Step 1: Create the label design in BarTender

My first step is to use the BarTender and design the label. I create the Named Data Sources and populate it with data. Here I have 3 data elements like AccountNum as a QR code, CustomerName and CustomerAddress, and have just added some sample data to each of the named data sources.

Now I have a label design, and I next need to populate this design with some data through a web-service.

Step 2. Use the BarTender integration builder to create a WEB-Service.

The BarTender integration builder is a fantastic tool, that makes building a REST-based integration service easy to build. Just import the already created label design, and create a variable for each named data source as demonstrated in the following video. Here you see that I have created a variable for each named data source.

Step 3. Test the WEB-Service.

For testing the label printing, my preferred tool is insomnia. Here I very easily can test my new web-service. I create a Post where a JSON looks like the following: Here I add value to the variables.

I then click “Send”, and in the insomnia, it is reporting back that the label is printed. I did specify that I wanted a PDF version of the label, and here is what I got:

Step 4. Deploy the WEB-Service

The next step is to deploy the service, and how to do this is available in the BarTender documentation.

Preliminary Summary:

At this time, we have a working REST service that will send labels to a printer, by posting a JSON file towards a URL. Our next step is to have Dynamics 365 F&O to generate such a JSON from data and to send it to the webservice.

Chapter 2 : Collect and send data from Dynamics 365 to the webservice

To make this happen, I decided to create a very small extension with the purpose to build the JSON from any data within Dynamics 365. I will show this extension from a user perspective.

Screen 1: Label Types

The first screen created was a place where you could define label types. Each label type have a ID and a name. You can also choose to connect the label towards a Main table identifier or a source class for special cases. In addition, you may further connect to joined tables through a query relation. Then the user us adding named data sources, and each can be a field, display method, class method or a free text. You may also add default values.

In the header you will also have the option to log the label and to create some notes about the label.

Screen 2: Enable the ability to print label from any screen.

The next thing I did was to create an extension to SysSystemDefinedButtons. This allowed me to dynamically add a generic menu on ALL forms, and only if there was a label defined on any of the data sources in the form, a View and print menu will show. I can multiselect records and send them to be printed or logged.

Screen 3: Printed labels

As each print can be logged, each label generated will get a unique label ID, and where all named data source values will be filled based on the label type

If I look at the “header” view I will also see the JSON created.

And this gives me the following label.

Final Summary:

This very small extension gives us the ability to generate the necessary data that can be sent to the label printing webservice. It can also be a candidate to completely replace the standard label printing made available in in WMS module, and further enhance the ability to generate labels all over Dynamics 365. There is also a very simplified API, that allows for label printing to be automatically executed at certain steps. Like in WMS Wave Steps, so that when an action in the WMS mobile is performed, then the label is printed. This way of dealing with labels could also easily to extended to other scenario’s like commerce/POS. Or to generate customer return labels in eCommerce. The possibilities are endless. And as the F&O code basically just are building a JSON to be sent to a web-service the tool can also be used for other labeling software or other 3’rd party tools.

Will the ideas and X++ code be shared with the community?

There is only one way that this would be shared with the community, and that is if Microsoft takes ownership to the solution and makes sure that we in standard very easily can design and create new labeling concepts in external tools like BarTender. If you as a reader have reached to this section in the blogpost, then you can influence this by voting on a Microsoft idea made available here. If accepted by Microsoft they will get the code for free and must ensure that we as a community get a long-lasting best-of-breed solution for label printing.

3 thoughts on “D365: BarTender and label integration using REST API

  1. We’ve been using the DSI PrintEnvoy ISV to connect from D365 to Bartender. It’s worked quite well in terms of flexibility. While agreed that it would be preferred to use a standard solution, we actually went down this route because the out of the box behavior wouldn’t keep document routing settings and MS support couldn’t figure it out (we would change the layouts and/or printers in the document routing settings and subsequent prints would randomly use previous settings at times).

    Liked by 1 person

  2. Hi, you can use the electronic report to generate the JSON and document routing. The entire JSON body is configurable using electronic reporting, allowing you to set up any JSON structure. Moreover, by using electronic reporting, you can use any output format, not only JSON.

    However, minor customization must connect the document routing to the electronic reporting.

    Like

  3. There are a few new features coming in the next D365 releases connected to label printing. One is an enhancement to current document routing layouts. They are being replaced by new label layouts, which include capabilities set up custom data sources with joined tables, removing some of the customization work needed to add data to the labels. The new label layouts also allow for having repeating labels, for example, if you want to print item labels out of receiving or shipping work (similar to how wave labels currently work).

    In addition, there is a new feature in work which will allow calling an external service to print a label. Since we cannot be tied to a specific vendor, this will allow you to configure the shape of the HTTP(S) request that you make, allowing for integration with cloud native and on-premise (if you open up the firewall or create an Azure API) label printing services, including Zebra’s cloud printing service (https://developer.zebra.com/apis/sendfiletoprinter-model), LoftWare NiceLabel Cloud or BarTender configured with REST APIs.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.