我在自定义屏幕发布AP文档时遇到问题(screnid = AP501000)。如果我已经在屏幕AP Bill And Adjusment中创建了一些额外的字段,我在DAC APTran(UsrJobOrderNbr和usrNoSeriFaktur)中创建了2个字段。我将DAC扩展创建为名为APTranExtension。以下是sintaks:
using PX.Objects.CR;
using PX.Objects.EP;
using PX.Objects.FA;
using PX.Objects.PO;
using System;
using PX.Data;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.IN;
using PX.Objects.TX;
using PX.Objects.DR;
using PX.Objects.PM;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AP;
namespace SGLCustomization
{
[Serializable]
public class APTranExtension: PXCacheExtension<PX.Objects.AP.APTran>
{
#region UsrJobOrderNbr`enter code here`
public abstract class usrJobOrderNbr : IBqlField{}
[PXDBString(25, IsFixed = true, IsUnicode = true)]
[PXUIField(DisplayName="Job Order Nbr")]
[PXSelector(typeof(Search<JobOrderNbr.jobOrderNbrCD,
Where<JobOrderNbr.status,
Equal<statusActive>>>),
typeof(JobOrderNbr.customerID),
typeof(JobOrderNbr.status),
typeof(JobOrderNbr.usrJobOrderNoRef))]
public string UsrJobOrderNbr
{
get;
set;
}
#endregion
}
}
我还创建了名为APTaxTranExtension的DAC扩展,下面是sintaks:
using PX.Objects.CR;
using PX.Objects.EP;
using PX.Objects.FA;
using PX.Objects.PO;
using System;
using PX.Data;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.IN;
using PX.Objects.TX;
using PX.Objects.DR;
using PX.Objects.PM;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AP;
using PX.Objects.AR;
namespace SGLCustomization
{
[Serializable]
public class APTaxTranExtension: PXCacheExtension<PX.Objects.AP.APTaxTran>
{
#region UsrNoSeriFaktur
public abstract class usrNoSeriFaktur : IBqlTable{}
[PXDBString(50, IsFixed = true)]
[PXUIField(DisplayName = "No Seri Faktur / Additional Narration")]
public string UsrNoSeriFaktur { get; set; }
#endregion
}
}
我还在GLTranExtension中创建Extension DAC,以存储来自APTranExtension和APTaxTranExtension的值。以下是我的GLTranExtension的罪名:
using System;
using PX.Data;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.PM;
using PX.Objects.CR;
using PX.Objects.TX;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.GL;
namespace SGLCustomization
{
[Serializable]
public class GLTranExtension: PXCacheExtension<PX.Objects.GL.GLTran>
{
#region UsrJobOrderNbr
public abstract class usrJobOrderNbr : IBqlField{}
[PXDBString(25, IsFixed = true, IsUnicode = true)]
[PXUIField(DisplayName="Job Order Nbr")]
[PXSelector(typeof(Search<JobOrderNbr.jobOrderNbrCD,
Where<JobOrderNbr.status,
Equal<statusActive>>>),
//typeof(JobOrderNbr.jobOrderNbrCD),
typeof(JobOrderNbr.customerID),
typeof(JobOrderNbr.status))]
public string UsrJobOrderNbr{get;set;}
#endregion
#region UsrNoSeriFaktur
public abstract class usrNoSeriFaktur : IBqlTable { }
[PXDBString(75, IsFixed = true)]
[PXUIField(DisplayName = "No Seri Faktur / Additional Narration")]
public string UsrNoSeriFaktur { get; set; }
#endregion
#region UsrInvoiceNbr
public abstract class usrInvoiceNbr : IBqlTable { }
[PXDBString(60, IsFixed = true)]
[PXUIField(DisplayName = "Vendor Ref. / Customer Order")]
public string UsrInvoiceNbr { get; set; }
#endregion
}
}
我的目标是当我输入交易然后在屏幕发布AP文档(AP501000)中发布文档时,我的新附加字段中的所有值也已经发送到日记帐交易屏幕(GL301000)。
我已经创建了APReleaseProcessExtension BLC来提供它,但它没有用。以下是我的APReleaseProcessExtension代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.CT;
using PX.Objects.PM;
using SGLCustomization;
using SGLCustomization1;
namespace SGLCustomization1
{
public class APReleaseProcessExtension: PXGraphExtension<APReleaseProcess>
{
public delegate List<APRegister> ReleaseDocProcDel(JournalEntry je, ref APRegister doc, PXResult<APInvoice, CurrencyInfo, Terms, Vendor, Account> res, out PMRegister pmDoc);
public List<APRegister> ReleaseDocProc(JournalEntry je, ref APRegister doc, PXResult<APInvoice, CurrencyInfo, Terms, Vendor, Account> res, out PMRegister pmDoc, ReleaseDocProcDel del)
{
je.RowInserting.AddHandler<GLTran>((sender, e) =>
{
GLTran glTran = e.Row as GLTran;
APTran apTran = PXResult<APTran>.Current;
if (glTran != null && apTran != null)
{
APTranExtension apTex = PXCache<APTran>.GetExtension<APTranExtension>(apTran);
if (apTran != null && apTex.UsrJobOrderNbr != null)
{
GLTranExtension glTex = PXCache<GLTran>.GetExtension<GLTranExtension>(glTran);
glTex.UsrJobOrderNbr = apTex.UsrJobOrderNbr;
}
}
APInvoice api = PXResult<APInvoice>.Current;
if (api != null && api.InvoiceNbr != null)
{
GLTranExtension glTex = PXCache<GLTran>.GetExtension<GLTranExtension>(glTran);
glTex.UsrInvoiceNbr = api.InvoiceNbr;
}
APTaxTran apTax = PXResult<APTaxTran>.Current;
if (apTax != null)
{
APTaxTranExtension apTaxEx = PXCache<APTaxTran>.GetExtension<APTaxTranExtension>(apTax);
if (apTax != null && apTaxEx.UsrNoSeriFaktur != null)
{
GLTranExtension glTex = PXCache<GLTran>.GetExtension<GLTranExtension>((GLTran)e.Row);
glTex.UsrNoSeriFaktur = apTaxEx.UsrNoSeriFaktur;
}
}
});
return del(je, ref doc, res, out pmDoc);
}
#region Event Handlers
#endregion
}
}
请帮我提供目标,
答案 0 :(得分:2)
您正朝着正确的方向前进,但您忘记添加[PXOverride]属性。如果没有PXOverrideAttribute,则不会调用ReleaseDocProc方法。将调用基本图的ReleaseDocProc。
您应该始终为扩展中覆盖的方法指定PXOverrideAttribute。请注意,事件处理程序不应标记为PXOverrideAttribute。
所以最终的代码看起来就像那样(我修改了方法签名,因为它与Acu 5.3U6中的基本方法签名不兼容):
public class APReleaseProcessExtension : PXGraphExtension<APReleaseProcess>
{
public delegate List<APRegister> ReleaseDocProcDel(JournalEntry je, ref APRegister doc, PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res, bool isPrebooking, out List<INRegister> inDocs);
[PXOverride]
public List<APRegister> ReleaseDocProc(JournalEntry je, ref APRegister doc, PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res, bool isPrebooking, out List<INRegister> inDocs, ReleaseDocProcDel del)
{
je.RowInserting.AddHandler<GLTran>((sender, e) =>
{
GLTran glTran = e.Row as GLTran;
APTran apTran = PXResult<APTran>.Current;
if (glTran != null && apTran != null)
{
APTranExtension apTex = PXCache<APTran>.GetExtension<APTranExtension>(apTran);
if (apTran != null && apTex.UsrJobOrderNbr != null)
{
GLTranExtension glTex = PXCache<GLTran>.GetExtension<GLTranExtension>(glTran);
glTex.UsrJobOrderNbr = apTex.UsrJobOrderNbr;
}
}
});
return del(je, ref doc, res, isPrebooking, out inDocs);
}
}
我还从此代码中删除了TaxTran和Invoice相关扩展,以简化它。你可以轻松归还。
我希望这能回答你的问题。