【发布时间】:2022-10-20 03:09:13
【问题描述】:
我试图在项目描述的开头插入客户 ID。我相信这样做的两个机会是 1)在选择客户时和 2)如果客户已经被选择,则在选择模板时。我也相信我想扩展 PM.ProjectEntry 业务逻辑。我有两个问题:
-
当我尝试在 CustomerID 字段更新事件中选择客户记录时,使用扩展中源代码中的相同代码会给我一个错误。该错误在下面的代码中标识。
-
我有一个 TemplateID 字段更新事件,我认为是 DefaultFromTemplateProjectSettings 事件的扩展。没有错误,但描述字段没有被修改。
namespace PX.Objects.PM { public class ProjectEntry_Extension : PXGraphExtension<PX.Objects.PM.ProjectEntry> { #region Event Handlers // Attempt to modify the project description line after a customer has been selected protected virtual void _(Events.FieldUpdated<PMProject, PMProject.customerID> e, PXFieldUpdated baseMethod) { baseMethod(e.Cache, e.Args); if (e.Row != null) { // Line 3 of this select statement errors with: // Argument 1: cannot convert from 'PX.Objects.PM.ProjectEntry_Extension' to 'PX.Data.PXGraph' Customer customer = new PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>(this).Select(e.Row.CustomerID); if (customer != null) { e.Cache.SetValueExt<PMProject.description>(e.Row, customer.AcctCD + " " + e.Row.Description); } } } // Two attempts to modify the project descrition after the project template has been selected // Neither of these two codes error, they just don't update the project description field // "customer.AcctCD" would be determined similar to the above process that currently errors protected virtual void DefaultFromTemplateProjectSettings(PMProject prj, PMProject templ) { prj.Description = "customer.AcctCD" + ": " + templ.Description; } protected virtual void _(Events.FieldUpdated<PMProject, PMProject.templateID> e, PXFieldUpdated baseMethod) { baseMethod(e.Cache, e.Args); if (e.Row != null) { e.Cache.SetValueExt<PMProject.description>(e.Row, "customer.AcctCD" + ": " + e.Row.Description); } } #endregion } }在 PM.ProjectEntry 业务逻辑中,我发现了以下内容:
protected virtual void OnCopyPasteTasksInserted(ProjectEntry target, Dictionary<int, int> taskMap) { //this method is used to extend Copy in Customizations. }所以,我在我的定制中尝试了以下内容。没有错误,但在选择模板时不会改变项目描述。
protected virtual void OnDefaultFromTemplateTasksInserted(PMProject prj, PMProject templ, Dictionary<int, int> taskMap) { prj.Description = "CustomerID: " + templ.Description; }没有“CustomerID:”,即 DefaultFromTemplateProjectSettings 对象中使用的代码行。
【问题讨论】:
标签: acumatica