In Projects screen (PM301000) When I click the Status changed to Active State (By clicking the Activate Project the status Change to active from In planning) , I need to Create a Task (CR306020) in the activities tab add added as a row to it. also I need to pass some parameters from summary tab to task form. like;
PMProject.ContractCD = CRActivity.Subject
PMProject.StartDate =CRActivity.StartDate_Date
PMProject.OwnerID = CRActivity.OwnerID
below is the error I'm getting and the code
any help to resolve this
![](https://uploads-us-west-2.insided.com/acumatica-en/attachment/176bb1db-81a4-4946-ad98-57eb9a45a3c5.png)
sss
using PX.Api;
using PX.Data;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM.Extensions;
using PX.Objects.Common;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.CT;
using PX.Objects.EP;
using PX.Objects.Extensions.MultiCurrency;
using PX.Objects.GL;
using PX.Objects.GL.FinPeriods;
using PX.Objects.IN;
using PX.SM;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Data.BQL.Fluent;
using PX.Data.BQL;
using PX.Common;
using PX.Objects.PO;
using PX.Objects.SO;
using PX.Objects.CR.Extensions;
using PX.Api.ContractBased.UI;
using PX.Objects;
using PX.Objects.PM;
using static PX.Objects.CT.Contract;
namespace PX.Objects.PM
{
public class ProjectEntry_Extension : PXGraphExtension<PX.Objects.PM.ProjectEntry>
{
protected void PMProject_Status_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (PMProject)e.Row;
if (row != null && row.Status == ProjectStatus.Active)
{
// Acuminator disable once PX1043 SavingChangesInEventHandlers lJustification]
CreateTask(row);
}
}
private void CreateTask(PMProject project)
{
// Create a new task
CRActivity task = new CRActivity
{
// ClassID = CRActivityClass.Task, // Ensure the ClassID is set correctly
Subject = $"{project.ContractCD.Trim()} - {project.Description.Trim()}",
StartDate = project.StartDate,
// UIStatus = ActivityStatusListAttribute.Open.Trim(),
OwnerID = project.OwnerID
};
// Insert the task
PXCache taskCache = Base.Cachesatypeof(CRActivity)];
task = (CRActivity)taskCache.Insert(task);
taskCache.Persist(PXDBOperation.Insert);
}
}
}