Hi,
In the Projects screen, a client is wanting to have the description field from the Tasks tab to be copied across to the ‘Task Description’ custom field in the Revenue and Cost Budget tabs.
I have code set up from a previous request that copied over the Task ID column to these tabs, so I am just needing to add some additional logic to this code, but I am not sure how to achieve this.
The comments in the code starting with ‘ATTEMPT:’ show where I was adding in the logic to try and achieve this.
It publishes without any issues, but then when I try it out in the Projects screen, I get the error shown in the image below about an incorrect extension being requested.
What would you recommend for my next attempt?
Kind regards,
Andrew
protected void PMTask_UsrLineCtr_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (PMTask)e.Row;
PMTaskExt rowExt = row.GetExtension<PMTaskExt>();
// ATTEMPT: Grabbing the DAC extension for the PMRevenueBudget and PMCostBudget DACs
PMBudgetExt budgetExt = cache.GetExtension<PMBudgetExt>(row);
PMTask task = new PMTask();
task.ProjectID = row.ProjectID;
task.TaskID = row.TaskID;
task.Description = row.Description;
var selectCostBudget = new PXSelect<PMCostBudget,
Where<PMCostBudget.projectID, Equal<Required<PMCostBudget.projectID>>,
And<PMCostBudget.projectTaskID, Equal<Required<PMCostBudget.projectTaskID>>,
And<PMCostBudget.type, Equal<GL.AccountType.expense>>>>>(this.Base);
var selectRevenueBudget = new PXSelect<PMRevenueBudget,
Where<PMRevenueBudget.projectID, Equal<Required<PMRevenueBudget.projectID>>,
And<PMRevenueBudget.projectTaskID, Equal<Required<PMRevenueBudget.projectTaskID>>,
And<PMRevenueBudget.type, Equal<GL.AccountType.income>>>>>(this.Base);
bool costBudgetExists = false;
// If task already exists in the Cost Budget column, just update the LineCntr column
foreach (PMCostBudget budget in selectCostBudget.Select(task.ProjectID, task.TaskID))
{
budget.LineCntr = rowExt.UsrLineCtr;
costBudgetExists = true;
selectCostBudget.Update(budget);
}
bool revBudgetExists = false;
// If task already exists in the Cost Budget column, just update the LineCntr column
foreach (PMRevenueBudget budget in selectRevenueBudget.Select(task.ProjectID, task.TaskID))
{
budget.LineCntr = rowExt.UsrLineCtr;
revBudgetExists = true;
selectRevenueBudget.Update(budget);
}
if (!costBudgetExists) {
// Add task to Cost Budget Tab if it doesn't exist
PMCostBudget costBudget = new PMCostBudget();
costBudget.LineCntr = rowExt.UsrLineCtr;
costBudget.ProjectTaskID = task.TaskID;
selectCostBudget.Insert(costBudget);
}
if (!revBudgetExists) {
// Add task to Revenue Budget Tab if it doesn't exist
PMRevenueBudget revBudget = new PMRevenueBudget();
revBudget.LineCntr = rowExt.UsrLineCtr;
revBudget.ProjectTaskID = task.TaskID;
// ATTEMPT: This is how I was aiming to update the custom field with the Task description
budgetExt.UsrDescriptionExt = task.Description;
selectRevenueBudget.Insert(revBudget);
}
}
#endregion
}
}