Solved

Project Template not populating

  • 21 November 2023
  • 2 replies
  • 37 views

Userlevel 3
Badge +1

Hello I’m hoping someone can point me in the right direction on this.  I’m trying to create templates in a new environment that will pre-populate Accounts ans Sub Accounts based on the Template Selected.  We are using Payroll and 2023R1. The fields:

  • PMProject.BenefitExpenseAcctID
  • PMProject.BenefitExpenseSubID
  • PMProject.EarningsAcctID
  • PMProject.EarningsSubID
  • PMProject.TaxExpenseAcctID
  • PMProject.TaxExpenseSubID

Are all available on the form but not populating when I select the Template.  I have customized the Project Properties but when I unpublished the customization's it is still not working. 

 

In ProjectEntry.cs I did find a section that seems to be listing the items to copy but I’m not sure how to add things to it.  Any help would be great I have tried to follow other examples of people working with this but nothing seems to work.  Below is the code from the Handler.  

public virtual void DefaultFromTemplateProjectSettings(PMProject prj, PMProject templ)
{
prj.Description = templ.Description;
PXDBLocalizableStringAttribute.CopyTranslations<PMProject.description, PMProject.description>
(Caches[typeof(PMProject)], templ, Caches[typeof(PMProject)], prj);
prj.BudgetLevel = templ.BudgetLevel;
prj.CostBudgetLevel = templ.CostBudgetLevel;
prj.AccountingMode = templ.AccountingMode;
prj.TermsID = templ.TermsID;
prj.AutoAllocate = templ.AutoAllocate;
prj.LimitsEnabled = templ.LimitsEnabled;
prj.PrepaymentEnabled = templ.PrepaymentEnabled;
prj.PrepaymentDefCode = templ.PrepaymentDefCode;
prj.DefaultBranchID = templ.DefaultBranchID;
prj.DefaultSalesAccountID = templ.DefaultSalesAccountID;
prj.DefaultSalesSubID = templ.DefaultSalesSubID;
prj.DefaultExpenseAccountID = templ.DefaultExpenseAccountID;
prj.DefaultExpenseSubID = templ.DefaultExpenseSubID;
prj.DefaultAccrualAccountID = templ.DefaultAccrualAccountID;
prj.DefaultAccrualSubID = templ.DefaultAccrualSubID;
prj.CalendarID = templ.CalendarID;
prj.RestrictToEmployeeList = templ.RestrictToEmployeeList;
prj.RestrictToResourceList = templ.RestrictToResourceList;
prj.AllowOverrideCury = templ.AllowOverrideCury;
prj.AllowOverrideRate = templ.AllowOverrideRate;
prj.RateTableID = templ.RateTableID;
prj.AllocationID = templ.AllocationID;
prj.BillingID = templ.BillingID;
prj.ApproverID = templ.ApproverID;
prj.OwnerID = templ.OwnerID;
prj.AutomaticReleaseAR = templ.AutomaticReleaseAR;
prj.CreateProforma = templ.CreateProforma;
prj.ChangeOrderWorkflow = templ.ChangeOrderWorkflow;
prj.RetainagePct = templ.RetainagePct;
prj.BudgetMetricsEnabled = templ.BudgetMetricsEnabled;
prj.IncludeCO = templ.IncludeCO;
prj.RetainageMaxPct = templ.RetainageMaxPct;
prj.RetainageMode = templ.RetainageMode;
prj.SteppedRetainage = templ.SteppedRetainage;
prj.AIALevel = templ.AIALevel;
prj.LastProformaNumber = templ.LastProformaNumber;
prj.IncludeQtyInAIA = templ.IncludeQtyInAIA;

prj.DropshipExpenseAccountSource = templ.DropshipExpenseAccountSource;
prj.DropshipExpenseSubMask = templ.DropshipExpenseSubMask;
prj.DropshipReceiptProcessing = templ.DropshipReceiptProcessing;
prj.DropshipExpenseRecording = templ.DropshipExpenseRecording;

prj.VisibleInAP = templ.VisibleInAP;
prj.VisibleInGL = templ.VisibleInGL;
prj.VisibleInAR = templ.VisibleInAR;
prj.VisibleInSO = templ.VisibleInSO;
prj.VisibleInPO = templ.VisibleInPO;
prj.VisibleInTA = templ.VisibleInTA;
prj.VisibleInEA = templ.VisibleInEA;
prj.VisibleInIN = templ.VisibleInIN;
prj.VisibleInCA = templ.VisibleInCA;
prj.VisibleInCR = templ.VisibleInCR;

ContractBillingSchedule billing = PXSelect<ContractBillingSchedule, Where<ContractBillingSchedule.contractID, Equal<Current<PMProject.contractID>>>>.SelectSingleBound(this, new object[] { templ });
if (billing != null)
{
if (Billing.Current == null)
{
Billing.Current = Billing.Select();
}
if (Billing.Current != null)
{
Billing.SetValueExt<ContractBillingSchedule.type>(Billing.Current, billing.Type);
Billing.Update(Billing.Current);
}
}
}

 

icon

Best answer by Zoltan Febert 21 November 2023, 03:34

View original

2 replies

Userlevel 6
Badge +3

You need to override the function you found:

using System;
using PX.Data;
using PX.Objects.PR;

namespace PX.Objects.PM
{
public class ProjectEntryExt : PXGraphExtension<ProjectEntry>
{
[PXOverride]
public virtual void DefaultFromTemplateProjectSettings(PMProject prj, PMProject templ,
Action<PMProject, PMProject> baseMethod)
{
baseMethod?.Invoke(prj, templ);

var prjExt = prj.GetExtension<PMProjectExtension>();
var templExt = templ.GetExtension<PMProjectExtension>();

prjExt.BenefitExpenseAcctID = templExt.BenefitExpenseAcctID;
prjExt.BenefitExpenseSubID = templExt.BenefitExpenseSubID;
prjExt.EarningsAcctID = templExt.EarningsAcctID;
prjExt.EarningsSubID = templExt.EarningsSubID;
prjExt.TaxExpenseAcctID = templExt.TaxExpenseAcctID;
prjExt.TaxExpenseSubID = templExt.TaxExpenseSubID;
}
}
}

 

Userlevel 3
Badge +1

@Zoltan Febert  Thank you so much for your help!  I had to add a few more Objects to the Customization to get it to work but your code was a huge help getting it to work and should be usable for anyone wanting to add fields from the Template to the project as I’m sure I”m not the only one who needs it.  

 

If I can find you at the conference this year I owe you a beer!

 

-Greg 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved