I was asked to make what I thought would be a very simple customization, hide the Promised On field on the PO Order Entry page. I opened the PO301000 screen in the customization editor, highlighted Promised On, clicked Attributes and clicked Override on Screen Level. I changed the resulting code on POOrderEntry to:
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
#region Event Handlers
[PXDBDate()]
[PXDefault(typeof(POOrder.orderDate), PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Promised On", Visibility = PXUIVisibility.Visible, Visible = false)]
protected virtual void POOrder_ExpectedDate_CacheAttached(PXCache cache)
{
}
#endregion
}
}
To my surprise, it did not work, the Promised On field is still visible and I do not know why. The version is 18.100.0062.
It looks like there is a RowSelected event in POOrderEntry that sets the visibility based on if it is a blanket PO. Since this is later in the chain of events it overrides the CacheAttached event.
You can get what you want by adding your own RowSelected event. Here's an example.
protected void POOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetVisible<POOrder.expectedDate>(cache, null, false);
}
GeorgeM use the code below. The trick is to call baseMethod before making changes to the visible state of the field.
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
[PXOverride]
protected virtual void POOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseMethod)
{
baseMethod(cache, e);
PXUIFieldAttribute.SetVisible<POOrder.expectedDate>(cache, null, false);
}
}
}
Related
Good afternoon everyone,
I need your help, I want to record one or several records on the PM301000 Projects screen in the detail tab, Cost Budget.
When recording one or more records, two Mark for PO and Vendor ID fields must be disabled. When the condition of the Mark for PO field is equal to true.
I have used the RowPersisting event and it disables it but when I modify or leave the registry the fields are enabled again.
Please help me or tell me how I should do it, my code is as follows.
Thanks in advance.
namespace PX.Objects.PM
{
public class PMBudgetExt : PXCacheExtension<PX.Objects.PM.PMBudget>
{
#region UsrVendorID
[PXDBInt]
[PXUIField(DisplayName = "Vendor ID", Visibility = PXUIVisibility.Visible)]
[PXDimensionSelectorAttribute("VENDOR", typeof(Search<VendorR.bAccountID, Where<VendorR.type, Equal<BAccountType.vendorType>,
And<VendorR.status, Equal<BAccount.status.active>>>>),
typeof(VendorR.acctCD), new Type[] { typeof(VendorR.acctCD), typeof(VendorR.acctName) })]
public virtual int? UsrVendorID { get; set; }
public abstract class usrVendorID : PX.Data.BQL.BqlInt.Field<usrVendorID> { }
#endregion
#region UsrMarkforPO
[PXDBBool()]
[PXDefault(false)]
[PXUIField(DisplayName = "Mark for PO")]
public virtual bool? UsrMarkforPO { get; set; }
public abstract class usrMarkforPO : PX.Data.BQL.BqlBool.Field<usrMarkforPO> { }
#endregion
}
}
namespace PX.Objects.PM
{
public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
{
#region Event Handlers
protected void PMCostBudget_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
PMCostBudget newRow = (PMCostBudget)e.Row;
if (newRow == null) return;
PMBudgetExt newRowE = PXCache<PMBudget>.GetExtension<PMBudgetExt>(newRow);
if (Base.CostBudget.Cache.AllowUpdate == true)
{
if (newRowE.UsrMarkforPO == true)
{
PXUIFieldAttribute.SetEnabled<PMBudgetExt.usrMarkforPO>(cache, newRow, false);
PXUIFieldAttribute.SetEnabled<PMBudgetExt.usrVendorID>(cache, newRow, false);
}
}
}
#endregion
}
}
RowPersisting event executes only on save event. Therefore it's not suited for setting the field states. You will get better results with RowSelected event which is executed everytime a record is selected to be displayed on screen. You should set the state on every callback whether it is enabled or disabled. Also, the event should be declared on the same DAC type you are using to set the field state so the cache object match.
public void PMBudget_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected del)
{
if (del != null)
{
del(sender, e);
}
bool isFieldEnabled = [your_condition];
PXUIFieldAttribute.SetEnabled<PMBudget.field>(sender, e.Row, isFieldEnabled);
}
I'm trying to override the Cancel Order button in Purchase Order screen, but I didn't found the Acumatica existing source code in POOrderEntry.
Can anyone help me on this. Thanks in advance.
Technically you can do the following:
public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
{
public MyCancelButton<POOrder> Cancel;
}
public sealed class MyCancelButton<TNode> : PXCancel<TNode> where TNode : class, IBqlTable, new()
{
public MyCancelButton(PXGraph graph, string name) : base(graph, name)
{
}
public MyCancelButton(PXGraph graph, Delegate handler) : base(graph, handler)
{
}
[PXUIField(DisplayName = "Cancel", MapEnableRights = PXCacheRights.Select)]
[PXCancelButton]
protected override IEnumerable Handler(PXAdapter adapter)
{
//DO SOME STAFF HERE
throw new PXException("Very bad idea");
return base.Handler(adapter);
}
}
But I DON'T RECOMMEND you doing that because the "Cancel" action is doing a lot of very important staff and messing it up is pretty easy.
I recommend considering other ways to do what you want to do. May be to place the logic in the Persisting or Verifying handlers.
so I'm trying to add a small bool field to the SOInvoiceEntry graph, so it can be exposed to the API. It needs to remain editable even after the document has been closed and released. I've set up the DAC field as:
public class ARRegisterExt : PXCacheExtension<PX.Objects.AR.ARRegister>
{
[PXDBBool]
[PXUIField(DisplayName="Has been integrated", Visibility = PXUIVisibility.Visible, Enabled = true)]
public virtual bool? UsrIsIntegrated { get; set; }
public abstract class usrIsIntegrated : IBqlField { }
}
And added RowSelected events which should, in theory, be setting the field to enabled:
public class SOInvoiceEntry_Extensions : PXGraphExtension<SOInvoiceEntry>
{
[PXOverride]
public void SOInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseMethod)
{
baseMethod?.Invoke(sender, e);
if (e.Row == null) return;
PXUIFieldAttribute.SetEnabled<ARRegisterExt.usrIsIntegrated>(sender, e.Row, true);
}
}
However the field remains readonly on closed invoices. I've tested this on the ARInvoiceEntry graph, and exposed that to the api, and it works fine. I've been testing different methods of setting the field as enabled, but no luck so far.
Any help would be awesome.
Thanks
Issue was caused by an automation step on the SOInvoiceEntry screen setting the ARInvoice table as disabled, which was overriding the logic I was adding.
I'd like to enable or disable a button upon selecting a line in a grid, here's what I tried for now :
public virtual void ARRegister_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARRegister row = e.Row as ARRegister;
if (row == null) return;
UnProcessLettering.SetEnabled(row.GetExtension<ARRegisterLeExt>().LettrageCD != null);
}
And I've set the syncposition as true in my grid. But nothing changes when I select a row in which LettrageCD is not null or is null.
Edit : it seems my question is a duplicate : Is there any event triggered when highlighting a row? (didnt find it during my first search :( )
Instead of calling SetEnabled on the PXAction, use the StateColumn property on your button aspx declaration.
When you declare your button, you specify a Boolean DAC field that will enable/disable the button based on it's value. Note that the button needs the DependOnGrid property set to the ID of the grid to get the selected row:
<px:PXToolBarButton Text="Button A" DependOnGrid="grid" StateColumn="IsButtonVisible">
IsButtonVisible is a custom unbound Boolean DAC field:
#region IsButtonVisible
public abstract class isButtonVisible : IBqlField
{
}
protected bool? _IsButtonVisible;
[PXBool]
[PXUIField(DisplayName = "Is Button Visible", Enabled = false, Visible = false)]
public virtual bool? IsButtonVisible
{
get
{
return _IsButtonVisible;
}
set
{
_IsButtonVisible = value;
}
}
#endregion
You can set the value of IsButtonVisible in the RowSelected event based on your business logic:
protected virtual void DAC_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
DAC row = e.Row as DAC;
if (row != null)
{
bool yourCondition = ???;
row.IsButtonVisible = yourCondition;
}
}
Source:
Enable disable button of grid or PXToolBarButton, which depends from value of column in Acumatica
How can I show QtyOnHand in IN402000 to the PO 301000 detail grid?
The POLine DAC already has a "QtyAvail (Qty on Hand)" field. You would simply need to create a customization project, add the screen, navigate to the Grid: Transactions and add the Control for the field to the screen & publish.
If you need to add the field to PO Line and the Quantity Available from INItemStatus would suffice you could add it with:
using System;
using PX.Data;
using PX.Objects.PO;
using PX.Objects.IN;
public class POLine_Extension : PXCacheExtension<POLine> {
[PXDecimal]
[PXUIField(DisplayName = "Qty Avail", Enabled = false)]
[PXDBScalar(typeof(
Search<INSiteStatus.qtyAvail,
Where<INSiteStatus.inventoryID, Equal<POLine.inventoryID>,
And<INSiteStatus.siteID, Equal<POLine.siteID>>>>))]
public virtual decimal? QtyAvail { get; set; }
public abstract class qtyAvail : IBqlField {}
}
Then the PXDBScalar fields have their values set when the DAC is Selected. There's probably a better way this could be done, but to populate the field as lines are added & updated to the PO within a POOrderEntry graph extension, you could handle the FieldUpdated events for the InventoryID and SiteID to execute a function that retrieves the Qty Available using basically the same BQL and sets that value to the DAC extension field.
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
public virtual void POLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
UpdateQtyAvailable(sender, e);
}
public virtual void POLine_SiteID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
UpdateQtyAvailable(sender, e);
}
private void UpdateQtyAvailable(PXCache sender, PXFieldUpdatedEventArgs e)
{
if (e.Row == null) return;
POLine row = (POLine)e.Row;
foreach(INSiteStatus siteStatus in PXSelect<INSiteStatus,
Where<INSiteStatus.inventoryID, Equal<Required<INSiteStatus.inventoryID>>,
And<INSiteStatus.siteID, Equal<Required<INSiteStatus.siteID>>>>>.Select(sender.Graph, row.InventoryID, row.SiteID))
{
sender.SetValueExt<POLine_Extension.qtyAvail>(row, siteStatus.QtyAvail);
}
}
}