Skip to main content
Answer

Creating SOShipLine failed

  • November 17, 2020
  • 1 reply
  • 229 views

SadokHanini
Freshman II

Im trying to create a Shipment 
but i have an issue with the lines,  creation fails but i have no error 
here the code below, help pls 

protected void createShip(List<SOShipLine> listOfShipLine, SOShipment shipment, SOOrder order)

{

var query2 = Contact.Select(new object[] { }).RowCast<Contact>().Where(s => s.FullName == "HYGIENNE CONSEILS").ToList();

var testContactId = query2[0].ContactID;

var location = Location.Select(new object[] { }).RowCast<Location>().Where(s => s.BAccountID == testContactId).ToList();

var rdv = PXAccess.GetOrganizations().

FirstOrDefault(o => string.Compare(o.OrganizationName, "RDV", true) == 0);

var graph = PXGraph.CreateInstance<SOShipmentEntry>();

var shipmentInstance = graph.Document.Insert(shipment);

shipment.CustomerID = query2[0].ContactID;

shipment.CustomerLocationID = location[0].LocationID;

graph.Document.Insert(shipment);

graph.Actions.PressSave();

foreach(SOShipLine ShipLine in listOfShipLine)

{

SOShipLine line = new SOShipLine();

line.CustomerID = query2[0].ContactID;

line.ShipmentNbr = shipment.ShipmentNbr;

line.ShipmentType = ShipLine.ShipmentType;

line.LineNbr= ShipLine.LineNbr;

line.SortOrder= ShipLine.SortOrder;

line.ShipDate= ShipLine.ShipDate;

line.LineType= ShipLine.LineType;

line.InventoryID= ShipLine.InventoryID;

line.SubItemID= ShipLine.SubItemID;

line.SiteID= ShipLine.SiteID;

line.LocationID= ShipLine.LocationID;

line.LotSerialNbr= ShipLine.LotSerialNbr;

line.InvtMult= ShipLine.InvtMult;

line.Operation= ShipLine.Operation;

line.OrigOrderType= ShipLine.OrigOrderType;

line.OrigOrderNbr= order.OrderNbr;

line.OrigLineNbr= ShipLine.OrigLineNbr;

line.OrigSplitLineNbr= ShipLine.OrigSplitLineNbr;

line.OrderUOM= ShipLine.OrderUOM;

line.UOM= ShipLine.UOM;

line.CompleteQtyMin= ShipLine.CompleteQtyMin;

line.ShippedQty= ShipLine.ShippedQty;

line.BaseShippedQty= ShipLine.BaseShippedQty;

line.BaseOriginalShippedQty= ShipLine.BaseOriginalShippedQty;

line.UnassignedQty= ShipLine.UnassignedQty;

line.OrigOrderQty= ShipLine.OrigOrderQty;

line.BaseOrigOrderQty= ShipLine.BaseOrigOrderQty;

line.UnitCost= ShipLine.UnitCost;

line.ExtCost= ShipLine.ExtCost;

line.UnitPrice= ShipLine.UnitPrice;

line.DiscPct= ShipLine.DiscPct;

line.CreatedByScreenID = ShipLine.CreatedByScreenID;

line.TranDesc= ShipLine.TranDesc;

line.UnitWeigth= ShipLine.UnitWeigth;

line.UnitVolume= ShipLine.UnitVolume;

line.ExtWeight= ShipLine.ExtWeight;

line.ExtVolume= ShipLine.ExtVolume;

line.ProjectID= ShipLine.ProjectID;

line.CreatedDateTime = ShipLine.CreatedDateTime;

line.IsFree= ShipLine.IsFree;

line.ManualPrice= ShipLine.ManualPrice;

line.ManualDisc= ShipLine.ManualDisc;

line.DiscountsAppliedToLine= ShipLine.DiscountsAppliedToLine;

line.DiscountID= ShipLine.DiscountID;

line.DiscountSequenceID= ShipLine.DiscountSequenceID;

line.PackedQty= ShipLine.PackedQty;

line.BasePackedQty= ShipLine.BasePackedQty;

line.CreatedByID = ShipLine.CreatedByID;

line.Confirmed= ShipLine.Confirmed;

line.Released= ShipLine.Released;

line.IsUnassigned= ShipLine.IsUnassigned;

line.PlanType= ShipLine.PlanType;

line.OrigPlanType= ShipLine.OrigPlanType;

line.ShipComplete= ShipLine.ShipComplete;

line.RequireINUpdate= ShipLine.RequireINUpdate;

graph.Transactions.Insert(line);

graph.Actions.PressSave();

}


throw new PXRedirectRequiredException(graph, null);

}

 

Best answer by Naveen Boga

Hi @SadokHanini,

 

I’m NOT sure, from which screen you are trying to create the shipment. Instead of having writing code you can invoke the CreateShipment default Acumatica method as below by providing the required values.
 

SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>();
                            soShipmentGraph.Clear();

                            //--------Create Shipment------------
                            DocumentList<SOShipment> created = new DocumentList<SOShipment>(soShipmentGraph);
                            soShipmentGraph.CreateShipment(soOrderGraph.Document.Current, siteId, soOrderGraph.Document.Current.OrderDate, false, SOOperation.Issue, created);

1 reply

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • November 17, 2020

Hi @SadokHanini,

 

I’m NOT sure, from which screen you are trying to create the shipment. Instead of having writing code you can invoke the CreateShipment default Acumatica method as below by providing the required values.
 

SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>();
                            soShipmentGraph.Clear();

                            //--------Create Shipment------------
                            DocumentList<SOShipment> created = new DocumentList<SOShipment>(soShipmentGraph);
                            soShipmentGraph.CreateShipment(soOrderGraph.Document.Current, siteId, soOrderGraph.Document.Current.OrderDate, false, SOOperation.Issue, created);