Hello Everyone,
We are trying to create a new project from webhook but it is giving “CURYID” cannot be empty error with below code. I have assigned curyid field in the code as well, but getting same exception.
public class Testwebhookclass : PXGraph<Testwebhookclass>, IWebhookHandler
{
public async Task<System.Web.Http.IHttpActionResult> ProcessRequestAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
var resultresponse = new OkResult(request);
var projectGraph = PXGraph.CreateInstance<ProjectEntry>();
//Customer customer = PXSelect<Customer, Where<Customer.acctCD, Equal<Required<Customer.acctCD>>>>.Select(projectGraph, customerCD);
PMProject objNewProject = new PMProject();
objNewProject.ContractCD = "TestPJ1";
objNewProject = projectGraph.Project.Insert(objNewProject);
// objNewProject.CustomerID = customer.BAccountID;
//objNewProject = projectGraph.Project.Update(objNewProject);
PMProject Templatedetails = PXSelect<PMProject, Where<PMProject.contractCD, Equal<Required<PMProject.contractCD>>>>.Select(projectGraph, "INTERNAL");
objNewProject.TemplateID = Templatedetails?.ContractID;
//projectGraph.Project.Cache.SetValueExt<PMProject.templateID>(objNewProject, Templatedetails.ContractID);
//objNewProject.CuryID = "USD";
//objNewProject.DefaultBranchID = 16;
projectGraph.DefaultFromTemplate(objNewProject, Templatedetails.ContractID, new ProjectEntry.DefaultFromTemplateSettings()
{
CopyProperties = true,
CopyTasks = true,
//CopyBudget = false,
CopyAttributes = true,
//CopyRecurring = false,
//CopyEmployees = false,
//CopyEquipment = false,
CopyNotification = true,
CopyAccountMapping = true,
CopyCurrency = true
});
objNewProject.Description = "Test project name";
objNewProject = projectGraph.Project.Update(objNewProject);
projectGraph.Actions.PressSave();
return resultresponse;
}
}
The same code is working fine in the custom button without using webhook. Why it is not working through webhook?
Can anyone suggest the approach to create a project from webhook?
Thanks