Hi I have implemented copying some custom fields from sales order header to the shipment header screen which works as expected.
Now I need some custom field values copied from sales order line to the shipment line screen, I’ve implemented the below but I get the error below.
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Data.WorkflowAPI;
using PX.Common;
using PX.Objects.AR;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.SM;
using PX.Objects.IN.DAC.Accumulators;
using PX.Objects.IN.Overrides.INDocumentRelease;
using POLineType = PX.Objects.PO.POLineType;
using POReceiptLine = PX.Objects.PO.POReceiptLine;
using PX.CarrierService;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.SO.Services;
using PX.Objects.PO;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Common.Collection;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.SO.GraphExtensions.SOShipmentEntryExt;
using PX.Api;
using LocationStatus = PX.Objects.IN.Overrides.INDocumentRelease.LocationStatus;
using ShipmentActions = PX.Objects.SO.SOShipmentEntryActionsAttribute;
using PdfSharp.Pdf.IO;
using PX.Objects.IN.Attributes;
using PX.Concurrency;
using PX.Objects.SO.GraphExtensions.SOOrderEntryExt;
using PX.Objects.GL.FinPeriods.TableDefinition;
using PX.Objects.GL.FinPeriods;
using PX.Objects;
using PX.Objects.SO;
namespace PX.Objects.SO
{
public class SOShipmentEntry_Extension : PXGraphExtension<PX.Objects.SO.SOShipmentEntry>
{
#region Event Handlers
public delegate void CreateShipmentDelegate(CreateShipmentArgs args);
PXOverride]
public void CreateShipment(CreateShipmentArgs args, CreateShipmentDelegate baseMethod)
{
// Call the original method to ensure default behavior
baseMethod(args);
// Retrieve the current shipment and order
SOShipment ship = Base.Document.Current;
SOOrder order = args.Order;
if (ship != null && order != null)
{
// Use the extension cache to access the custom fields
SOShipmentExt shipExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(ship);
SOOrderExt orderExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(order);
// Update custom fields in the shipment header
shipExt.UsrCommission = orderExt.UsrCommission;
shipExt.UsrCustomerPickUp = orderExt.UsrCustomerPickUp;
shipExt.UsrDuty = orderExt.UsrDuty;
shipExt.UsrFreight = orderExt.UsrFreight;
shipExt.UsrInsurance = orderExt.UsrInsurance;
shipExt.UsrQtyShow = orderExt.UsrQtyShow;
shipExt.UsrQtyNote = orderExt.UsrQtyNote;
// Update and save the shipment header
Base.Document.Update(ship);
Base.Save.Press();
}
}
// Event handler for SOShipLine RowPersisting
protected virtual void SOShipLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
SOShipLine shipLine = (SOShipLine)e.Row;
if (shipLine == null) return;
// Query the Sales Order Line for the current shipment line
SOLine orderLine = PXSelect<SOLine,
Where<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>
.Select(Base.Base, shipLine.SOOrderNbr, shipLine.SOOrderLineNbr);
if (orderLine != null)
{
SOShipLineExt shipLineExt = PXCache<SOShipLine>.GetExtension<SOShipLineExt>(shipLine);
SOLineExt lineExt = PXCache<SOLine>.GetExtension<SOLineExt>(orderLine);
// Copy custom field value from SOLine to SOShipLine
shipLineExt.UsrBrand = lineExt.UsrBrand;
// Update the shipment line
sender.Update(shipLine);
}
}
#endregion
}
}
p2024-07-29 04:58:51.153] \App_Code\Caches\SOShipmentEntry.cs(100): error CS1061: 'SOShipmentEntry' does not contain a definition for 'Base' and no accessible extension method 'Base' accepting a first argument of type 'SOShipmentEntry' could be found (are you missing a using directive or an assembly reference?)
p2024-07-29 04:58:51.153] \App_Code\Caches\SOShipmentEntry.cs(100): error CS1061: 'SOShipLine' does not contain a definition for 'SOOrderNbr' and no accessible extension method 'SOOrderNbr' accepting a first argument of type 'SOShipLine' could be found (are you missing a using directive or an assembly reference?)
p2024-07-29 04:58:51.154] \App_Code\Caches\SOShipmentEntry.cs(100): error CS1061: 'SOShipLine' does not contain a definition for 'SOOrderLineNbr' and no accessible extension method 'SOOrderLineNbr' accepting a first argument of type 'SOShipLine' could be found (are you missing a using directive or an assembly reference?)
p2024-07-29 04:58:51.156] \App_Code\Caches\SOShipmentEntry.cs(100): error CS1061: 'SOShipmentEntry' does not contain a definition for 'Base' and no accessible extension method 'Base' accepting a first argument of type 'SOShipmentEntry' could be found (are you missing a using directive or an assembly reference?)
p2024-07-29 04:58:51.158] Compiler time, in seconds: 19.5998106
How can I achieve this functionality? Any help would be appreciated, thank you!