Status: IPrjStatus;
The Status property returns found errors or warnings on creating a project plan.
To check whether there are errors or warnings in project plan, use the IPrjProject.CheckConstraints method.
To work with an error or warning on creating a project plan, use the IPrjStatusItem interface.
To execute the example, add a link to the ProjectPlanning system assembly.
Sub UserProc;
Var
Project: IPrjProject;
Tasks: IPrjTaskCollection;
Task: IPrjTask;
Depend: IPrjTaskDependency;
Status: IPrjStatus;
Error: IPrjStatusItem;
Errors: IPrjStatusCollection;
Key: Integer;
Begin
Project := New PrjProject.Create;
// Set project start date
Project.StartDate := DateTime.Parse("20.02.2020");
Project.UseStartDate := True;
// Get collection of project tasks
Tasks := Project.Tasks;
// Create the first task
Task := Tasks.Add;
Task.Key := 1;
Task.Name := "№1";
// Create the second task
Task := Tasks.Add;
Task.Key := 2;
Task.Name := "№2";
Task.ParentKey := 2; // parent task key
Depend := Task.Dependencies.Add;
Depend.PredecessorTaskKey := 2;
// Check if project has any errors
If Project.CheckConstraints = True Then
Debug.WriteLine("No errors");
Else
Status := Project.Status;
// Get the first found error
Errors := Status.Errors;
Error := Errors.Item(0);
// Display the key of the task with error, code and error message to the console
For Each Key In Error.Keys Do
Debug.WriteLine("Key of the task with error: " + Key.ToString);
End For;
Debug.WriteLine("Error code: " + Error.Code.ToString);
Debug.WriteLine("Message: " + Error.Message);
End If;
End Sub UserProc;
After executing the example, the console displays the key of the first found task with error, error code and message on creating a project plan:
Key of the task with error: 2
Error code: 1
Message: Work 2 cannot be a parent to itself
See also: