Today we are going to write that how to add a custom column in the sales order grid and show that custom column in the shipment grid.
Firstly, you need to add that column in the sales_shipment table and sales_shipment_grid table via declarative scema.
You need to add this file to the custom module
Magemonkeys/ModuleName/view/adminhtml/ui_component/sales_order_shipment_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_shipment_columns">
<column name="new_fieldname">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">New field column name</item>
<item name="visible" xsi:type="boolean">false</item>
</item>
</argument>
</column>
</columns>
</listing>
Copy column value to grid table.
For that need to create di.xml file in Magemonkeys/ModuleName/etc/
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="MagentoSalesModelResourceModelOrderShipmentGrid" type="MagentoSalesModelResourceModelGrid">
<arguments>
<argument name="columns">
<item name="new_fieldname" xsi:type="string">sales_shipment.new_fieldname</item>
</argument>
</arguments>
</virtualType>
</config>
That’s it.

