samol518
samol518

Reputation: 1404

Why do I need 2 API call to add an unconfirmed package to shipment

When I try to add a package to a shipment, even if I put the confirmed value to false, Acumatica seems to overwrite it with the true value.

Here is the code sample I am using for my first call as the second one is only setting the confirmed value to false again.

static void Main(string[] args)
{
    DefaultSoapClient client = new DefaultSoapClient();
    client.Login("admin", "admin", "Company", null, null);

    Shipment ship = new Shipment
    {
        ShipmentNbr = new StringSearch { Value = "001301", Condition = StringCondition.Equal },
        Packages = new ShipmentPackage[]
        {
            new ShipmentPackage
            {
                BoxID = new StringValue {Value = "Large" },
                Confirmed = new BooleanValue {Value=false },
                Weight = new DecimalValue {Value = 1.5m }
            }
        }
    };
    client.Put(ship);
    client.Logout();
}

Upvotes: 0

Views: 64

Answers (1)

samol518
samol518

Reputation: 1404

The issue here is that there is an event in the SOShipment Graph (SOPackageDetail_Weight_FieldUpdated) which will change the value of the confirmed checkbox to true when the weigh field is updated.

A simple fix for this is to add a small customization, that will disable the content of that event when using the contract based API.

public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{

    #region Event Handlers

    protected void SOPackageDetail_Weight_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
    {
        if (InvokeBaseHandler != null)
            if (!Base.IsContractBasedAPI)
                InvokeBaseHandler(sender, e);
    }
    #endregion
}

Though if you do not want this event to happen at any other time you could always add the event but leave it empty.

Upvotes: 2

Related Questions