This seems like one of those simple requests. I actually did this for the same client on SOLine but on CROpportunityProducts I’m not having any luck.
This works when new line added to CROpportunityProducts:
protected virtual void CROpportunityProducts_Quantity_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e, PXFieldDefaulting baseEvent)
{
baseEvent?.Invoke(sender, e);
CROpportunityProducts row = e.Row as CROpportunityProducts;
if (row == null) return;
if (!row.Quantity.HasValue && Base.IsImport != true)
{
e.NewValue = row.Quantity = 1M;
}
}
But when inventory item is selected, quantity goes back to 0. I saw there is an attribute (PXDBOpportunityProductQuantityAttribute) so I’ve attempted every combination of removing/overriding this using CacheAttached.
This doesn’t work:
pPXDefault(TypeCode.Decimal, "0.0")]
PXUIField(DisplayName = "Quantity", Visibility = PXUIVisibility.Visible)]
protected virtual void CROpportunityProducts_Quantity_CacheAttached(PXCache sender) { }
And this doesn’t work either:
aPXRemoveBaseAttribute(typeof(PXDBOpportunityProductQuantityAttribute))]
protected virtual void CROpportunityProducts_Quantity_CacheAttached(PXCache sender) { }
Quantity goes back to zero after selecting inventory item no matter what. I tried FieldUpdated event and this doesn’t work either:
protected virtual void CROpportunityProducts_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated baseEvent)
{
baseEvent?.Invoke(sender, e);
CROpportunityProducts row = e.Row as CROpportunityProducts;
if (row != null && row.InventoryID != null)
{
sender.SetValueExt<CROpportunityProducts.quantity>(e.Row, 1M);
}
}
Any ideas?