Hey guys,
I am having an issue with a custom action I have written, I think, in accordance with the T190 training course.
Below is the error I get:
This is my code for the method & the action:
//method declaration
private static void createQCCheck(AMBatch batch)
{
using (var ts = new PXTransactionScope())
{
var qCEntry = PXGraph.CreateInstance<GCQualityControlEntry>();
QualityControl doc = new QualityControl() { };
// AMMTran batch = new AMMTran();
doc = qCEntry.QCCheck.Insert(doc);
doc.BatchNbr = batch.BatNbr;
doc.Date = batch.TranDate;
qCEntry.QCCheck.Update(doc);
var batchEntry = PXGraph.CreateInstance<MoveEntry>();
batchEntry.batch.Current = batch;
foreach (AMMTran line in batchEntry.transactions.Select())
{
var lines = qCEntry.Details.Insert();
lines.AMProdOrdID = line.ProdOrdID;
qCEntry.Details.Update(lines);
}
qCEntry.Actions.PressSave();
ts.Complete();
}
}
//Action declaration
public PXAction<AMBatch> CreateQCCheck;
PXButton(DisplayOnMainToolbar = true)]
PXUIField(DisplayName = "Start QC Checks", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
protected virtual IEnumerable createQCCheck(PXAdapter adapter)
{
List<AMBatch> list = new List<AMBatch>();
foreach(AMBatch batch in adapter.Get<AMBatch>())
{
list.Add(batch);
}
var batches = AMBatches.Current;
PXLongOperation.StartOperation(this, delegate () { createQCCheck(batches); });
return list;
}