on 07-23-2020 2:16 PM
Hi!
I created one custom BO called ProjectbaselineCostCenters that has a [0,n] node called Studiengange which is translation of cost centers in German. I wrote this logic in ProjectBaseline BO extension in the BeforeSave event.
import ABSL;
import AP.Common.GDT as apCommonGDT;
import AP.FO.MOM.Global;
import AP.ProjectManagement.Global;
var ProjectbaselineCostCenter = ProjectbaselineCostCenters.Retrieve(this.UUID);
if (!ProjectbaselineCostCenter.IsSet())
{
//Baseline
var pbData : elementsof ProjectbaselineCostCenters;
var pbccData : elementsof ProjectbaselineCostCenters.Studiengange;
var pbccsData : collectionof elementsof ProjectbaselineCostCenters.Studiengange;
//Project
var query = Project.QueryByCreationIdentity;
var para = query.CreateSelectionParams();
para.Add(query.ProjectID.content, "I", "EQ", this.BaseProjectID.content);
var project = query.Execute(para);
if (project.Count() > 0)
{
var ProjectCostCentersInstance = ProjectCostCenters.Retrieve(project.GetFirst().UUID);
foreach (var cc in ProjectCostCentersInstance.Studiengange)
{
pbccData.Studiengang = cc.Studiengang;
pbccData.StudiengangsID = cc.StudiengangsID;
pbccsData.Add(pbccData);
}
pbData.BaseProjectID = this.BaseProjectID;
pbData.ProjectbaselineUUID = this.UUID;
ProjectbaselineCostCenter = ProjectbaselineCostCenters.Create(pbData);
if (ProjectbaselineCostCenter.Studiengange.Count() < 1)
{
ProjectbaselineCostCenter.Studiengange.CreateMass(pbccsData); //Dump here!!!!!!
}
}
}<br>
I want to create a ProjectbaselineCostCenters object at every time I create the project baseline. I wrote the above logic but I have null exception at like 57 which is the last line of code. What is wrong in there?
Thanks,
Mousa
Mousa,
You have the below code snippet. You're not checking whether ProjectbaselineCostCenter is set after you call the .Create() --- so my guess is that 'if (ProjectbaselineCostCenter.Studiengange.Count() < 1)' is the line that's crashing, because it's trying to access the Studiengange node of an object that may not exist.
var ProjectbaselineCostCenter = ProjectbaselineCostCenters.Retrieve(this.UUID);
if (!ProjectbaselineCostCenter.IsSet())
{
...
ProjectbaselineCostCenter = ProjectbaselineCostCenters.Create(pbData);
if (ProjectbaselineCostCenter.Studiengange.Count() < 1)
{
ProjectbaselineCostCenter.Studiengange.CreateMass(pbccsData); //Dump here!!!!!!
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.