Skip to main content
Solved

NoteID error when creating new custom screen record from Move Screen

  • 3 July 2024
  • 3 replies
  • 60 views

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;
}

 

3 replies

Userlevel 5
Badge +2

Hey all,

Just as an update, I have reset cache and restarted the application in case anything was stuck in the cache.

I have checked the source data and the database and couldn’t find the NoteID specified in the error message.

Userlevel 5
Badge +2

Hi All,

I am not experienced enough to know what exactly caused the bug, however, I managed to overcome it by dropping the NoteID column from the DB and reintroducing it.

If anyone would like to share their thoughts on why this could have happened, I would greatly appreciate it.

Hope you all have a lovely day!

Userlevel 7
Badge

Thank you for sharing your solution with the community @aiwan!

Reply