Skip to main content
Solved

UPS Label Custom Reference remove prefix

  • January 19, 2025
  • 4 replies
  • 59 views

Hello,

Not a C# developer, and very new to acumatica.

Using the below code I was able to figure out how to add the CustomerOrderNbr and ShipmentNbr to the package ex custom reference nbr 1 & 2. The label is generated using the UPS Rest carrier.

My issue is the the very lengthy prefix as seen in my attached image. How do I remove the custom reference prefixes “Reference No.1” and “Reference No.2”

Also below is my code. Please let me know if I need to add anything like cache updating. Currently the code works but other examples included some cache update code I did not understand.

 

    protected void SOPackageDetailEx_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting InvokeBaseHandler)
    {
      if(InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);
      var row = (SOPackageDetailEx)e.Row;
      SOOrderShipment shipment = PXSelect<SOOrderShipment, Where<SOOrderShipment.shipmentNbr, Equal<Required<SOPackageDetailEx.shipmentNbr>>>>.Select(Base, row.ShipmentNbr);
      if (shipment == null) return;
      SOOrder order = PXSelect<SOOrder, Where<SOOrder.orderNbr, Equal<Required<SOOrderShipment.orderNbr>>>>.Select(Base, shipment.OrderNbr);
      if (order == null) return;
      row.CustomRefNbr1 = "Purchase No.:" + order.CustomerOrderNbr;
      row.CustomRefNbr2 = "Invoice No.:" + row.ShipmentNbr;
    }

 

Best answer by jmcmichael

I did it!!

I modified the PX.UpsRestCarrier.dll then restarted my computer. Super excited to generate the label perfectly the way I want.

I’m not sure if my crestwood provider will replace the dll for me but that doesn’t matter anymore I’ve got a fix and its management’s problem now.

Attached is label generated with modified dll.

 

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+6
  • Captain II
  • 554 replies
  • January 19, 2025

I think you just need to remove the prefixes here I think:

      row.CustomRefNbr1 = "Purchase No.:" + order.CustomerOrderNbr;
      row.CustomRefNbr2 = "Invoice No.:" + row.ShipmentNbr;

Becomes:

      row.CustomRefNbr1 = order.CustomerOrderNbr;
      row.CustomRefNbr2 = row.ShipmentNbr;

Unless I’m missing something.

The training materials are fairly well done so I’d recommend working your way through them. I didn’t start on my Acumatica journey as a C# developer, either. My recommendation (because this is how my brain works) is to print out the documentation and then write notes on it so that as you figure out the bits and pieces you can really dissect the code.


  • Author
  • Freshman II
  • 7 replies
  • January 20, 2025

In the UPS rest api under packages there is “ReferenceNumber” using the codes PO and IK I get the data I want purchase and invoice number

Attached is an image when I generate the label using their API directly:

Is there rest code in acumatica I could edit(customize) to add these package reference numbers?

    protected function createPayload(Shipment $shipment): array
    {
        return [
            'ShipmentRequest' => [
                'Request' => [
                    'TransactionReference' => [
                        'CustomerContext' => 'Shipment and Service',
                    ],
                ],
                'Shipment' => [
                    'Shipper' => $shipment->getShipper(),
                    'ShipTo' => $shipment->getShipTo(),
                    'ShipFrom' => $shipment->getShipFrom(),
                    'Package' => [
                        'Packaging' => [
                            'Code' => '02',
                            'Description' => 'Package',
                        ],
                        'Dimensions' => $shipment->getDimensions(),
                        'PackageWeight' => $shipment->getPackageWeight(),
                        'ReferenceNumber' => [
                            [
                                'Code' => 'PO',
                                'Value' => 'TestOrd1'
                            ],
                            [
                                'Code' => 'IK',
                                'Value' => 'TestInv1'
                            ]
                        ]
                    ],
                    'PaymentInformation' => [
                        'ShipmentCharge' => [
                            'Type' => '01',
                            'BillShipper' => [
                                'AccountNumber' => config('ups.merchant_id'),
                            ]
                        ]
                    ],
                    'Service' => [
                        'Code' => '03',
                        'Description' => 'Ground'
                    ],
                ],
                'LabelSpecification' => [
                    'LabelImageFormat' => [
                        'Code' => 'GIF',
                        'Description' => 'GIF'
                    ],
                    'HTTPUserAgent' => 'Mozilla/4.5'
                ],
            ],

 


  • Author
  • Freshman II
  • 7 replies
  • January 20, 2025

I was poking around the acumatica source code and found the PX.UpsRestCarrier.dll

I used some software called dnSpy to poke around it.

Could I potentially get someone to modify the dll to change the Code from “01” and “02” to “PO” and “IK”

The code is under their CreateShipmentRequest function which generates the request body to the ups rest api endpoint.

I don’t even know if I’d be able to integrate the new dll back into acumatica or if this is against their terms.

Attached is a screenshot


  • Author
  • Freshman II
  • 7 replies
  • Answer
  • January 20, 2025

I did it!!

I modified the PX.UpsRestCarrier.dll then restarted my computer. Super excited to generate the label perfectly the way I want.

I’m not sure if my crestwood provider will replace the dll for me but that doesn’t matter anymore I’ve got a fix and its management’s problem now.

Attached is label generated with modified dll.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings