Skip to Content
0
Jul 23, 2020 at 01:16 PM

A Null exception every time I try to create a custom BO instance from a standard BO.

75 Views

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