Search code examples
csomproject-server

Event Handler later than OnPublished


Are there any Project Server event handler events later than the "OnPublished"-event when creating a new project?

The time when the on published event occurs seems to be to early. Loading the project FieldValues does not work. They are always null.

PublishedProject project = projCollection.First().IncludeCustomFields;
projectContext.Load(project);
projectContext.Load(project.IncludeCustomFields);
CustomFieldCollection fields = project.CustomFields;
projectContext.Load(fields);
projectContext.ExecuteQuery();

Dictionary<string, object> fieldValues = project.FieldValues;

When executing the same code for an existing project everything works fine.

Instead I could do a timeout for x seconds but I would prefer a later server event where all values have already been set.

Edit:

Seems there was something wrong with my other code before executing this. Custom Fields and FieldValues are loading correctly now.

But loading the projectSiteUrl afterwards is still to early at this point. The ProjectSiteUrl stays null.

projectContext.Load(project, p => p.ProjectSiteUrl);
projectContext.ExecuteQuery();

Solution

  • Once a project is completely published, OnProjectChangedRemote event of ReportingEventReceiver Class gets fired.

    When a new project is created and the creation process completes, OnProjectCreatedRemote event of ReportingEventReceiver Class gets fired.