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));
    		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
    Tuesday, May 27, 2014 2:55 PM

All replies

  • So anybody can help me ?

    The only solution i have is to change required custom field in optionnal custom field before the script and re change after.

    But i would like to do it without that trick :/

    Monday, June 02, 2014 11:14 AM
  • HI!

    Did you find a solution for this? Im facing the same problem!!


    Tuesday, July 08, 2014 7:25 PM
  • Hi.

    Unfortunaly no :( I change my required fields to optional before start my script and change them after to required.


    Tuesday, July 08, 2014 7:42 PM
  • Man, the MS documentation is really crappy! I can't believe that just us want to accomplish this task!


    Tuesday, July 08, 2014 8:05 PM
  • I am also facing issues. Can we all discuss on this as a group?

    Thursday, July 10, 2014 9:33 AM
  • Yes we can :)

    The CSOM doesn't cover every functionality. Maybe it is possible with the PSI. Personaly I didn't have time to search in that direction.

    Thursday, July 10, 2014 7:27 PM
  • 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;
                      // 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.

    Thursday, July 10, 2014 8:15 PM
  • Whats the error details that you are getting?
    Friday, July 11, 2014 5:41 AM
  • Hi.

    I already have a similar problem with the project owner. I just can't assign a project owner :/ No error that just don't work. Maybe it is the same with the responsible of a task :(

    Monday, July 21, 2014 8:11 AM
  • I agree, I cannot update an owner from CSOM (my post:  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.


    Monday, August 25, 2014 5:08 PM