We've created a webpart and user control that uses a sharepoint people picker to save AD accounts to a project custom field.
To save, we've hooked into the ProjectSave event (click 'Save' on the ribbon) using a page component.
After the save callback is triggered and we've updated the custom field, PWA complains that, "the project is out of date" and has been, "updated in another session." That's obviously our doing.
Our suspicion is that someone tracks the last updated date/time and notices that it's changed since being created.
Thanks for any suggestions.
Update
void OnSaveProject()
{
ProjectDataSet projectDataSet = ProjWeb.project.ReadProjectEntities(ProjectUid, (int)(ProjectEntityType.ProjectCustomFields | ProjectEntityType.Project), SvcProject.DataStoreEnum.PublishedStore);
//ProjectDataSet projectDataSet = ProjWeb.project.ReadProject(ProjectUid, SvcProject.DataStoreEnum.PublishedStore);
ProjectDataSet.ProjectRow project = projectDataSet.Project[0];
if (!project.IsPROJ_CHECKOUTBYNull() && project.PROJ_SESSION_UID != null)
{
Guid fieldGuid;
// skip if this customfield is not set
//
if (!String.IsNullOrEmpty(ProjectServerCustomFieldAccounts))
{
fieldGuid = ProjWeb.customFields.GetCustomField(ProjectServerCustomFieldAccounts);
if (!ProjWeb.SetCustomValue(projectDataSet, project.PROJ_SESSION_UID, fieldGuid, PeopleEditor.CommaSeparatedAccounts))
{
PpWebPart.Log("Error at SetCustomValue to value" + PeopleEditor.CommaSeparatedAccounts);
}
}
}
Then, SetCustomValue:
public bool SetCustomValue(SvcProject.ProjectDataSet forProject, Guid sessionUId, Guid field, String value)
{
Guid ciJobId = Guid.NewGuid();
foreach (SvcProject.ProjectDataSet.ProjectCustomFieldsRow r in forProject.ProjectCustomFields)
{
if (r.MD_PROP_UID.Equals(field))
{
if (r.TEXT_VALUE.Equals(value)) return false;
r.TEXT_VALUE = value;
project.QueueUpdateProject(ciJobId, sessionUId, forProject, false);
queueSystem.WaitFor(ciJobId);
return true;
}
}
return false;
}