Reputation: 35
Tell me please how I can Hide the ADD LC button, since it is defined in the acumatica code that it is displayed by condition.
This is the standard acumatica code that displays this button
#region Actions
public PXAction<APInvoice> addLandedCost;
public PXAction<APInvoice> addLandedCost2;
[PXUIField(DisplayName = "Add LC", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]
[PXLookupButton]
[APMigrationModeDependentActionRestriction(
restrictInMigrationMode: true,
restrictForRegularDocumentInMigrationMode: true,
restrictForUnreleasedMigratedDocumentInNormalMode: true)]
public virtual IEnumerable AddLandedCost(PXAdapter adapter)
{
if (Base.Document.Current != null &&
Base.Document.Current.Released != true)
{
if (LandedCostDetailsAdd.AskExt((graph, view) =>
{
landedCostFilter.Cache.ClearQueryCacheObsolete();
landedCostFilter.View.Clear();
landedCostFilter.Cache.Clear();
LandedCostDetailsAdd.Cache.ClearQueryCacheObsolete();
LandedCostDetailsAdd.View.Clear();
LandedCostDetailsAdd.Cache.Clear();
}, true) == WebDialogResult.OK)
{
return AddLandedCost2(adapter);
}
}
return adapter.Get();
}
[PXUIField(DisplayName = "Add LC", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]
[PXLookupButton]
[APMigrationModeDependentActionRestriction(
restrictInMigrationMode: true,
restrictForRegularDocumentInMigrationMode: true,
restrictForUnreleasedMigratedDocumentInNormalMode: true)]
public virtual IEnumerable AddLandedCost2(PXAdapter adapter)
{
if (Base.Document.Current != null &&
Base.Document.Current.DocType.IsIn(APDocType.Invoice, APDocType.DebitAdj) &&
Base.Document.Current.Released == false &&
Base.Document.Current.Prebooked == false)
{
var landedCostDetails = LandedCostDetailsAdd.Cache.Updated.RowCast<POLandedCostDetailS>().Where(t => t.Selected == true).ToArray();
Base.AddLandedCosts(landedCostDetails);
landedCostDetails.ForEach(t => t.Selected = false);
}
return adapter.Get();
}
#endregion
#region Events
protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
APInvoice document = e.Row as APInvoice;
if (document == null) return;
var invoiceState = Base.GetDocumentState(cache, document);
addLandedCost.SetVisible(invoiceState.IsDocumentInvoice || invoiceState.IsDocumentDebitAdjustment);
PXUIFieldAttribute.SetEnabled(LandedCostDetailsAdd.Cache, null, false);
bool allowAddLandedCost = invoiceState.IsDocumentEditable &&
invoiceState.LandedCostEnabled &&
!invoiceState.IsRetainageDebAdj;
addLandedCost.SetEnabled(allowAddLandedCost);
PXUIFieldAttribute.SetEnabled<POLandedCostDetailS.selected>(LandedCostDetailsAdd.Cache, null, allowAddLandedCost);
}
This line indicates under what condition to display. How can I override this condition in my extension class in APInvoice_RowSelected? e.g. display only if (invoiceState.IsDocumentInvoice)
addLandedCost.SetVisible(invoiceState.IsDocumentInvoice || invoiceState.IsDocumentDebitAdjustment);
Upvotes: 0
Views: 722
Reputation: 771
Artem,
I would write an event override
protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
{
baseHandler.Invoke(cache, e);
// Now put your custom .SetEnabled function here and it will run after the base handler runs
}
Upvotes: 1