Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Set required custom field during project creation

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>