Asked by:
Set required custom field during project creation

-
Hi.
I am developping a script for Project Server 2013 with the Project Client API.
I already have create project without any required field and set values to my custom fields.
But recently i change a field to be required and i got the Exception : PJClientCallableException: CustomFieldRequiredValueNotProvided.
But the value is set and when the field is not required the value exists when i look at the projects.
Here my code to create the project :
/// <summary> /// Create a project /// </summary> private PublishedProject CreateProject(ProjectsLoopEventArgs args) { PublishedProject project = null; // Define required informations ProjectCreationInformation projInfo = new ProjectCreationInformation(); projInfo.Id = Guid.NewGuid(); projInfo.Name = args.Title; projInfo.Description = args.Description; projInfo.Start = args.Start.Date; projInfo.EnterpriseProjectTypeId = this.ProjectType; // Create the project project = this.Context.Projects.Add(projInfo); return project; } /// <summary> /// Update the project /// </summary> private void UpdateProject(PublishedProject project, ProjectsLoopEventArgs args) { // set custom field values pProject.SetCustomFieldValue(this.InternalNames[CUSTOM_FIELD_NAME_REFERENCE], args.Reference); // my required custom field // update the project QueueJob qJob = this.Context.Projects.Update(); JobState jobState = this.Context.WaitForQueue(qJob, this.Arguments.Timeout); if (jobState != JobState.Success) { OnQueueErrorEvent(new QueueErrorEventArgs(args, jobState, this.Arguments.Timeout)); } else { OnProjectAddedEvent(new ProjectAddedEventArgs(args)); } }
With that code and field optionnal the project are created.
But when the field is required i have an exception.
Any ideas ?
- Edited by Drakta Tuesday, May 27, 2014 2:58 PM
Question
All replies
-
-
-
-
-
-
-
Sure, maybe this could help someone.
Now Im fighting with Tasks. I just want to set the responsibles for the Task, but is not working!!:
foreach (DraftTask t in draft.Tasks){
AssignmentCreationInformation info = new AssignmentCreationInformation();
info.Id = Guid.NewGuid();
info.ResourceId = new Guid("{fa72372a-e1fb-e311-8d09-00155dbc2908}");
info.TaskId = t.Id;
info.Start = System.DateTime.Today;
info.Finish = System.DateTime.Today;
t.Assignments.Add(info);
// p.ActualWorkTimeSpan = new TimeSpan(6, 1, 20);
}Any other property i set works fine (just like the commented one) . but why, the assignments dont?
weeks working on it and only a few methods created.
-
-
-
I agree, I cannot update an owner from CSOM (my post: http://social.msdn.microsoft.com/Forums/en-US/bc46720c-3da6-4ef9-b3ae-5c3c43bc42d5/csom-bugs?forum=project2010custprog) and I can't figure it out from REST either.
There is no documentation on MSDN regarding these topics, and they are not responding to any threads like this. Its very frustrating.
120811049008