Hi Everyone,
In the Stock Items, I’m trying to update the existing record with the below code but it is still trying to insert a new record in the Cross-Reference tab.
Can anyone help on this?
public delegate void PersistDelegate();
PXOverride]
public void Persist(PersistDelegate del)
{
try
{
InventoryItem row = Base.Item.Current;
if (row != null)
{
CSAnswers objCSAnswers = PXSelect<CSAnswers, Where<CSAnswers.refNoteID, Equal<Required<CSAnswers.refNoteID>>,
And<CSAnswers.attributeID, Equal<Required<CSAnswers.attributeID>>>>>.Select(Base, row.NoteID, "ALTID");
if (objCSAnswers != null && !string.IsNullOrEmpty(objCSAnswers.Value))
{
row.GetExtension<InventoryItemCExt>().UsrCAlternateID = objCSAnswers.Value;
INItemXRef objINItemXRef = PXSelect<INItemXRef, Where<INItemXRef.inventoryID, Equal<Required<INItemXRef.inventoryID>>,
And<INItemXRefCExt.usrCAltIDExists, Equal<boolTrue>,
And<INItemXRef.alternateType, Equal<INAlternateType.global>>>>>.Select(Base, row.InventoryID);
if (objINItemXRef != null)
{
INItemXRefCExt refExt = objINItemXRef.GetExtension<INItemXRefCExt>();
if (objINItemXRef.InventoryID == row.InventoryID && refExt.UsrCAltIDExists == true && objINItemXRef.AlternateType == INAlternateType.Global)
{
objINItemXRef.AlternateID = objCSAnswers.Value.Trim();
Base.itemxrefrecords.Cache.Update(objINItemXRef);
}
}
}
}
del();
}
catch (Exception ex)
{
throw ex;
}
}