Skip to main content
Answer

Customization to Change default value for move

  • February 25, 2025
  • 6 replies
  • 98 views

Forum|alt.badge.img

I am trying to change the default lookup value for a field. I am wanting to make the “Operation ID” default to the last value instead of the first. screenshot below. I thought it might be as simple as changing the order of the Dac from asc to desc (screenshot below) but that didnt seem to do anything.. i tried doing that in the customized data classes screen and with a graph extension but neither seemed to work. Can someone point me in the direction of where to change this at? I also tried looking at the business logic and only found where it specified to retrieve the data but not the default value. I am still learning the acumatica framework, so any help would be greatly appreciated.

 

Best answer by Samvel Petrosov

It looks like there is another defaulting logic on that page that works when the Production Nbr field is assigned a value.

This is in PX.Objects.AM.MoveEntryBase<TWhere>

protected virtual void AMMTran_ProdOrdID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
AMMTran ammTran = (AMMTran)e.Row;
if (string.IsNullOrWhiteSpace((ammTran != null) ? ammTran.ProdOrdID : null))
{
return;
}
if (this.ampsetup.Current == null)
{
this.ampsetup.Current = PXSelectBase<AMPSetup, PXSelect<AMPSetup>.Config>.Select(this, Array.Empty<object>());
}
AMProdItem amproditem = (AMProdItem)PXSelectorAttribute.Select<AMMTran.prodOrdID>(sender, ammTran);
if (amproditem == null)
{
return;
}
int? firstOperationID = amproditem.FirstOperationID;
int? lastOperationID = amproditem.LastOperationID;
bool singleOpeation = firstOperationID.GetValueOrDefault() == lastOperationID.GetValueOrDefault() & firstOperationID != null == (lastOperationID != null);
bool flag = this.IsImport || this.IsContractBasedAPI;
if (flag && singleOpeation)
{
sender.SetValueExt<AMMTran.operationID>(ammTran, amproditem.LastOperationID);
}
if (!flag)
{
AMProdOper oper = this.ampsetup.Current.InclScrap.GetValueOrDefault() ? PXSelectBase<AMProdOper, PXSelectJoin<AMProdOper, InnerJoin<AMProdItem, On<AMProdOper.orderType, Equal<AMProdItem.orderType>, And<AMProdOper.prodOrdID, Equal<AMProdItem.prodOrdID>>>>, Where<AMProdOper.orderType, Equal<Required<AMProdOper.orderType>>, And<AMProdOper.prodOrdID, Equal<Required<AMProdOper.prodOrdID>>, And<Sub<AMProdItem.qtytoProd, Add<AMProdOper.qtyComplete, AMProdOper.qtyScrapped>>, Greater<decimal0>>>>, OrderBy<Asc<AMProdOper.operationCD>>>.Config>.SelectWindowed(this, 0, 1, new object[]
{
ammTran.OrderType,
ammTran.ProdOrdID
}) : PXSelectBase<AMProdOper, PXSelectJoin<AMProdOper, InnerJoin<AMProdItem, On<AMProdOper.orderType, Equal<AMProdItem.orderType>, And<AMProdOper.prodOrdID, Equal<AMProdItem.prodOrdID>>>>, Where<AMProdOper.orderType, Equal<Required<AMProdOper.orderType>>, And<AMProdOper.prodOrdID, Equal<Required<AMProdOper.prodOrdID>>, And<Sub<AMProdItem.qtytoProd, AMProdOper.qtyComplete>, Greater<decimal0>>>>, OrderBy<Asc<AMProdOper.operationCD>>>.Config>.SelectWindowed(this, 0, 1, new object[]
{
ammTran.OrderType,
ammTran.ProdOrdID
});
if (oper != null && oper.OperationID != null)
{
sender.SetValueExt<AMMTran.operationID>(ammTran, oper.OperationID);
}
else if (ammTran.OperationID == null)
{
sender.SetValueExt<AMMTran.operationID>(ammTran, amproditem.FirstOperationID);
}
}
sender.SetValueExt<AMMTran.inventoryID>(ammTran, amproditem.InventoryID);
sender.SetValueExt<AMMTran.subItemID>(ammTran, amproditem.SubItemID);
sender.SetValueExt<AMMTran.siteID>(ammTran, amproditem.SiteID);
sender.SetValueExt<AMMTran.locationID>(ammTran, amproditem.LocationID);
sender.SetValueExt<AMMTran.uOM>(ammTran, amproditem.UOM);
sender.SetValue<AMMTran.wIPAcctID>(ammTran, amproditem.WIPAcctID);
sender.SetValue<AMMTran.wIPSubID>(ammTran, amproditem.WIPSubID);
this.SyncTransactionAttributes(ammTran);
}

 

6 replies

Forum|alt.badge.img+5
  • Jr Varsity I
  • February 25, 2025

Hi @justen0351,

You are adding the description to the OperationCD field, but I believe you need to use the OperationID field instead.

Please try replacing OperationCD with OperationID.

Hope, it helps!


Forum|alt.badge.img
  • Author
  • Varsity III
  • February 25, 2025

@Ankita Tayana Thank you for the reponse. i tried changing it to operationID but it is still pulling the lowest operation id instead of the highest.

 


Samvel Petrosov
Jr Varsity II
Forum|alt.badge.img+8
  • Jr Varsity II
  • Answer
  • February 25, 2025

It looks like there is another defaulting logic on that page that works when the Production Nbr field is assigned a value.

This is in PX.Objects.AM.MoveEntryBase<TWhere>

protected virtual void AMMTran_ProdOrdID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
AMMTran ammTran = (AMMTran)e.Row;
if (string.IsNullOrWhiteSpace((ammTran != null) ? ammTran.ProdOrdID : null))
{
return;
}
if (this.ampsetup.Current == null)
{
this.ampsetup.Current = PXSelectBase<AMPSetup, PXSelect<AMPSetup>.Config>.Select(this, Array.Empty<object>());
}
AMProdItem amproditem = (AMProdItem)PXSelectorAttribute.Select<AMMTran.prodOrdID>(sender, ammTran);
if (amproditem == null)
{
return;
}
int? firstOperationID = amproditem.FirstOperationID;
int? lastOperationID = amproditem.LastOperationID;
bool singleOpeation = firstOperationID.GetValueOrDefault() == lastOperationID.GetValueOrDefault() & firstOperationID != null == (lastOperationID != null);
bool flag = this.IsImport || this.IsContractBasedAPI;
if (flag && singleOpeation)
{
sender.SetValueExt<AMMTran.operationID>(ammTran, amproditem.LastOperationID);
}
if (!flag)
{
AMProdOper oper = this.ampsetup.Current.InclScrap.GetValueOrDefault() ? PXSelectBase<AMProdOper, PXSelectJoin<AMProdOper, InnerJoin<AMProdItem, On<AMProdOper.orderType, Equal<AMProdItem.orderType>, And<AMProdOper.prodOrdID, Equal<AMProdItem.prodOrdID>>>>, Where<AMProdOper.orderType, Equal<Required<AMProdOper.orderType>>, And<AMProdOper.prodOrdID, Equal<Required<AMProdOper.prodOrdID>>, And<Sub<AMProdItem.qtytoProd, Add<AMProdOper.qtyComplete, AMProdOper.qtyScrapped>>, Greater<decimal0>>>>, OrderBy<Asc<AMProdOper.operationCD>>>.Config>.SelectWindowed(this, 0, 1, new object[]
{
ammTran.OrderType,
ammTran.ProdOrdID
}) : PXSelectBase<AMProdOper, PXSelectJoin<AMProdOper, InnerJoin<AMProdItem, On<AMProdOper.orderType, Equal<AMProdItem.orderType>, And<AMProdOper.prodOrdID, Equal<AMProdItem.prodOrdID>>>>, Where<AMProdOper.orderType, Equal<Required<AMProdOper.orderType>>, And<AMProdOper.prodOrdID, Equal<Required<AMProdOper.prodOrdID>>, And<Sub<AMProdItem.qtytoProd, AMProdOper.qtyComplete>, Greater<decimal0>>>>, OrderBy<Asc<AMProdOper.operationCD>>>.Config>.SelectWindowed(this, 0, 1, new object[]
{
ammTran.OrderType,
ammTran.ProdOrdID
});
if (oper != null && oper.OperationID != null)
{
sender.SetValueExt<AMMTran.operationID>(ammTran, oper.OperationID);
}
else if (ammTran.OperationID == null)
{
sender.SetValueExt<AMMTran.operationID>(ammTran, amproditem.FirstOperationID);
}
}
sender.SetValueExt<AMMTran.inventoryID>(ammTran, amproditem.InventoryID);
sender.SetValueExt<AMMTran.subItemID>(ammTran, amproditem.SubItemID);
sender.SetValueExt<AMMTran.siteID>(ammTran, amproditem.SiteID);
sender.SetValueExt<AMMTran.locationID>(ammTran, amproditem.LocationID);
sender.SetValueExt<AMMTran.uOM>(ammTran, amproditem.UOM);
sender.SetValue<AMMTran.wIPAcctID>(ammTran, amproditem.WIPAcctID);
sender.SetValue<AMMTran.wIPSubID>(ammTran, amproditem.WIPSubID);
this.SyncTransactionAttributes(ammTran);
}

 


Forum|alt.badge.img
  • Author
  • Varsity III
  • March 6, 2025

Thank you ​@Samvel Petrosov. I believe that points me in the right direction.


Forum|alt.badge.img
  • Jr Varsity III
  • June 16, 2025

@justen0351 

I’ve needed to do the same thing. I made an event handler like this:

protected void AMMTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{

var row = (AMMTran)e.Row;
if (row == null) return;

AMProdItem amproditem = (AMProdItem)PXSelectorAttribute.Select<AMMTran.prodOrdID>(cache, row);

if (amproditem != null){
row.OperationID = amproditem.LastOperationID;
}
}

 


Forum|alt.badge.img
  • Author
  • Varsity III
  • June 20, 2025

@u662 below is how i did it. I ended up having Daryl Bowman help me with writing this.