从 Acumatica Framework 中的 SOShipLine 中删除行
Delete row from SOShipLine in Acumatica Framework
美好的一天,
我需要从“发货”屏幕上的 SOShipLine 中删除一行
screenshot of action
我正在对 SOShipmentEntry 进行扩展,并尝试执行以下操作以删除该行
PXResultset<SOShipLine> shipLines = SelectFrom<SOShipLine>.InnerJoin<SOShipment>.On<SOShipLine.shipmentNbr.IsEqual<SOShipment.shipmentNbr>>
.Where<SOShipLine.shipmentNbr.IsEqual<@P.AsString>>.View.Select(Base, shipment.ShipmentNbr);
List<Linelevel> lineLevels = osr.Transaction.Transaction.Order.LineLevel;
foreach (SOShipLine shipLine in shipLines)
{
Linelevel lineLevel = lineLevels.Find(lineNbr => lineNbr.POLineNum == shipLine.LineNbr);
if (lineLevel != null)
{
shipLine.ShippedQty = lineLevel.PickedQuantity;
} else
{
Base.Transactions.Cache.Delete(shipLine);
}
}
但是当我到达要删除行的位置时,它会生成一个异常,询问我密钥不能为 null
尝试直接使用“交易”视图,而不是使用 PXSelect 查询数据。
// This is no longer needed - retrieve from the Transactions view instead
//PXResultset<SOShipLine> shipLines = SelectFrom<SOShipLine>.InnerJoin<SOShipment>.On<SOShipLine.shipmentNbr.IsEqual<SOShipment.shipmentNbr>>
// .Where<SOShipLine.shipmentNbr.IsEqual<@P.AsString>>.View.Select(Base, shipment.ShipmentNbr);
List<Linelevel> lineLevels = osr.Transaction.Transaction.Order.LineLevel;
// Cycle through the records returned directly from the Transactions view
//foreach (SOShipLine shipLine in shipLines)
foreach (SOShipLine shipLine in Base.Transactions.Select())
{
Linelevel lineLevel = lineLevels.Find(lineNbr => lineNbr.POLineNum == shipLine.LineNbr);
if (lineLevel != null)
{
shipLine.ShippedQty = lineLevel.PickedQuantity;
} else
{
// Generally speaking, work with the view instead of the cache when possible
//Base.Transactions.Cache.Delete(shipLine);
Base.Transactions.Delete(shipLine);
}
}
// After your logic completes, make sure the user has to press Save or you do it for them
Base.Save.Press();
我通常只在处理不在视图中的其他一些数据时才直接使用缓存,例如将引用值推送到在别处管理的记录中。即便如此,我更喜欢在图形扩展中创建一个视图并使用它。
美好的一天,
我需要从“发货”屏幕上的 SOShipLine 中删除一行
screenshot of action
我正在对 SOShipmentEntry 进行扩展,并尝试执行以下操作以删除该行
PXResultset<SOShipLine> shipLines = SelectFrom<SOShipLine>.InnerJoin<SOShipment>.On<SOShipLine.shipmentNbr.IsEqual<SOShipment.shipmentNbr>>
.Where<SOShipLine.shipmentNbr.IsEqual<@P.AsString>>.View.Select(Base, shipment.ShipmentNbr);
List<Linelevel> lineLevels = osr.Transaction.Transaction.Order.LineLevel;
foreach (SOShipLine shipLine in shipLines)
{
Linelevel lineLevel = lineLevels.Find(lineNbr => lineNbr.POLineNum == shipLine.LineNbr);
if (lineLevel != null)
{
shipLine.ShippedQty = lineLevel.PickedQuantity;
} else
{
Base.Transactions.Cache.Delete(shipLine);
}
}
但是当我到达要删除行的位置时,它会生成一个异常,询问我密钥不能为 null
尝试直接使用“交易”视图,而不是使用 PXSelect 查询数据。
// This is no longer needed - retrieve from the Transactions view instead
//PXResultset<SOShipLine> shipLines = SelectFrom<SOShipLine>.InnerJoin<SOShipment>.On<SOShipLine.shipmentNbr.IsEqual<SOShipment.shipmentNbr>>
// .Where<SOShipLine.shipmentNbr.IsEqual<@P.AsString>>.View.Select(Base, shipment.ShipmentNbr);
List<Linelevel> lineLevels = osr.Transaction.Transaction.Order.LineLevel;
// Cycle through the records returned directly from the Transactions view
//foreach (SOShipLine shipLine in shipLines)
foreach (SOShipLine shipLine in Base.Transactions.Select())
{
Linelevel lineLevel = lineLevels.Find(lineNbr => lineNbr.POLineNum == shipLine.LineNbr);
if (lineLevel != null)
{
shipLine.ShippedQty = lineLevel.PickedQuantity;
} else
{
// Generally speaking, work with the view instead of the cache when possible
//Base.Transactions.Cache.Delete(shipLine);
Base.Transactions.Delete(shipLine);
}
}
// After your logic completes, make sure the user has to press Save or you do it for them
Base.Save.Press();
我通常只在处理不在视图中的其他一些数据时才直接使用缓存,例如将引用值推送到在别处管理的记录中。即便如此,我更喜欢在图形扩展中创建一个视图并使用它。