Logistics Automation - Parcel Label Generation
Tags: powerfuldevs, powerplatform, logistics, automation
Published: 2023-02-26 11:48:55

**Why Barcodes**?
Barcodes play an important role in delivery and parcel management systems

- **_Tracking Parcels_**: Barcodes are used to track parcels from the moment they are picked up to the point of delivery. Each parcel is assigned a unique barcode that can be scanned at every point in the delivery process. This enables real-time tracking of the parcel, so customers and businesses can stay informed about its location and estimated time of delivery.

- **_Sorting and Routing_**: Barcodes are used to sort and route parcels to their intended destinations. Sorting facilities use barcode scanners to scan each parcel as it arrives and sort it according to its destination. This ensures that parcels are delivered to the correct location and on time.

- **_Proof of Delivery_**: Barcodes are used to provide proof of delivery. Delivery drivers can scan the barcode on a parcel when it is delivered to confirm that it has been received. This provides a record of the delivery and helps to prevent disputes over whether a parcel was delivered.

In this blog we are exploring on creating a parcel label which we would leverage in the subsequent blog 

**Conceptual Architecture View**:



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uge0k3ahhpliqsutgzea.png)



**Platform Setup**:

1. **Data source / Sharepoint List setup**:
Setup a sharepoint list with some dummy data with the fields OrderID, Consignment ID (concatenation of OrderID, first 2 char of origin and destination Postcode), Origin PostCode, Destination Postcode, Packing Units, Cost and Status as a choice column


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ed82kdm9932ovltfc4hs.png)


2. **Basic selection screen**:
The goal is to filter Orders that are not printed for labels. Have a user selection dropdown which filters distinct Consignment IDs but selects only if the status of the order is set as "01". 

```
Distinct(Filter(GeoMap,Status.Value = "01"),'Consignment ID')
```
The **_onvisible_** property of the field is set not to be available for the print command

```
Not(Parent.Printing)
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syru4sk9yqzsesccifv2.png)


3. Created a Group to represent the Parcel label that needs to be printed as below


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc0ds4vo1tbffbgtxchy.png)

The "**_HtmlText2_1_**" object the HTML text is set leveraging the below HTML code to create a AS-128 Single line of barcode and the value is driven based on the selection of the field **_OrderID_** which is a user input 

```
"<head><title>Code-128 Barcode Generate</title><style>
      #barcode {
        font-size: 0;
        line-height: 0;
        white-space: nowrap;
        margin: 10px;
        border: 1px solid black;
        padding: 5px;
        display: inline-block;
      }
      #barcode::before {
        display: inline-block;
        height: 100%;
        vertical-align: middle;
      }
      #barcode img {
        display: inline-block;
        vertical-align: middle;
      }</style></head><body><div id='barcode'><img src='https://barcode.tec-it.com/barcode.ashx?data="&OrderID.SelectedText.Value&"&type=Code128&dpi=96'/></div></body>"
```

![Image description]
(https://media.giphy.com/media/wNpT35gMteg9UQRcLn/giphy.gif)


4. On the print function, we would update the base record to change the status to "02" using a patch function

```
Patch(GeoMap,LookUp(GeoMap,'Consignment ID'= OrderID.SelectedText.Result),{Status:{ Value: "02"}})
```

![Image description]
(https://media.giphy.com/media/boI4fKggw8mI7k2vYj/giphy.gif)


**Barcodes** play a critical role in delivery and parcel management systems, enabling real-time tracking, sorting, routing, and inventory management. They help to improve the efficiency and accuracy of the delivery process, which benefits both businesses and customers.