某些用户字段已添加到ARInvoice输入屏幕(AR301000)。用户字段存在于“事务”网格中。它们只是文本字段。没有关联的自定义逻辑,并且绑定到DB表。
用户希望在发票发布后修改特定的用户文本字段 - 实现此目的的最佳方法是什么?
答案 0 :(得分:0)
值得庆幸的是,ARInvoces输入屏幕上的交易网格永远不会被自动化步骤禁用。事务网格的所有UI表示逻辑仅在ARInvoiceEntry BLC中定义:
public class ARInvoiceEntry : ARDataEntryGraph<ARInvoiceEntry, ARInvoice>, PXImportAttribute.IPXPrepareItems
{
...
protected virtual void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
ARInvoice doc = e.Row as ARInvoice;
if (doc == null) return;
...
bool shouldDisable = doc.Released == true
|| doc.Voided == true
|| doc.DocType == ARDocType.SmallCreditWO
|| doc.PendingPPD == true
|| doc.DocType == ARDocType.FinCharge && !IsProcessingMode && cache.GetStatus(doc) == PXEntryStatus.Inserted;
if (shouldDisable)
{
...
Transactions.Cache.AllowDelete = false;
Transactions.Cache.AllowUpdate = false;
Transactions.Cache.AllowInsert = false;
...
}
else
{
...
Transactions.Cache.AllowDelete = true;
Transactions.Cache.AllowUpdate = true;
Transactions.Cache.AllowInsert =
doc.CustomerID != null &&
doc.CustomerLocationID != null &&
doc.DocType != ARDocType.FinCharge &&
(doc.ProjectID != null || !PM.ProjectAttribute.IsPMVisible(this, BatchModule.AR));
...
}
...
}
protected virtual void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARTran row = e.Row as ARTran;
if (row != null)
{
PXUIFieldAttribute.SetEnabled<ARTran.defScheduleID>(sender, row, row.TranType == ARInvoiceType.CreditMemo || row.TranType == ARInvoiceType.DebitMemo);
PXUIFieldAttribute.SetEnabled<ARTran.deferredCode>(sender, row, row.DefScheduleID == null);
}
}
...
}
要在ARInvoice发布后在AR301000上启用自定义字段,您应完成以下相关简单步骤:
为ARInvoice_RowSelected事件处理程序中的ARTran缓存设置 AllowUpdate 为 true
调用静态 PXUIFieldAttribute.SetEnabled 方法以禁用所有ARTran字段,但用户想要修改的特定自定义文本字段除外
下面列出了完整的代码段:
public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
private bool IsDisabled(ARInvoice doc)
{
return doc.Released == true
|| doc.Voided == true
|| doc.DocType == ARDocType.SmallCreditWO
|| doc.PendingPPD == true
|| doc.DocType == ARDocType.FinCharge
&& !Base.IsProcessingMode
&& Base.Document.Cache.GetStatus(doc) == PXEntryStatus.Inserted;
}
public void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
ARInvoice doc = e.Row as ARInvoice;
if (doc == null) return;
if (IsDisabled(doc))
{
Base.Transactions.Cache.AllowUpdate = true;
}
}
public void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
var doc = Base.Document.Current;
ARTran row = e.Row as ARTran;
if (row != null && doc != null && IsDisabled(doc))
{
PXUIFieldAttribute.SetEnabled(sender, row, false);
PXUIFieldAttribute.SetEnabled<ARTranExt.usrCustomTextField>(sender, row, true);
}
}
}