Skip to main content
Solved

Customization to Change default value for move

  • February 25, 2025
  • 6 replies
  • 167 views
  • Translate All

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

 

View original

6 replies

Forum|alt.badge.img+6

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!

Translate

Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • 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.

 

Translate

Samvel Petrosov
Jr Varsity III
Forum|alt.badge.img+9

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

 

Translate

Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • March 6, 2025

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

Translate

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

 

Translate

Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • June 20, 2025

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

 

Translate