How to save project custom field value thru PSI

C

ctd

Hello,
Using PSI, I'm creating a new project with assigned custom fields values.
My project was saved and published; however its custom fields values are just
blank, somehow they are not saved along with the project. My custom fields
are all pre-existing.

I excerpt the following from my code, hope someone can tell me what I am
missing here. I need to be able to display both the project and its custom
fields values in PWA project center. Thanks in advance.

// Create the project.
ProjectWS.ProjectDataSet.ProjectRow projectRow =
projectDs.Project.NewProjectRow();

projectRow.PROJ_UID = projguid;
projectRow.PROJ_NAME = ProjectName;
projectRow.CREATED_DATE = DateTime.Now.Date;
projectRow.PROJ_TYPE = (int)PSLib.Project.ProjectType.Project;
projectDs.Project.AddProjectRow(projectRow);

// Save the project to the database.
jobId = Guid.NewGuid();
projectSvc.QueueCreateProject(jobId, projectDs, false);
WaitForQueue(q, jobId);

// Publish the project.
jobId = Guid.NewGuid();
projectSvc.QueuePublish(jobId, projectRow.PROJ_UID, false, String.Empty);
WaitForQueue(q, jobId);

//Save custom fields
string strCustField = "Department";
mycustomDS = mycustom.ReadCustomFieldsByEntity(
new
Guid(PSLib.EntityCollection.Entities.ProjectEntity.UniqueId.ToString()));

DataView dataview = new DataView(mycustomDS.CustomFields);
dataview.RowFilter = mycustomDS.CustomFields.MD_PROP_NAMEColumn.ColumnName +
" = '" + strCustField + "'";

CustomFieldWS.CustomFieldDataSet.CustomFieldsRow rowCF =

(CustomFieldWS.CustomFieldDataSet.CustomFieldsRow)dataview[0].Row;

//Create a new custom field row
ProjectWS.ProjectDataSet.ProjectCustomFieldsRow newCFrow =
projectDs.ProjectCustomFields.NewProjectCustomFieldsRow();

//Setup the custom field
newCFrow.CUSTOM_FIELD_UID = Guid.NewGuid();
newCFrow.PROJ_UID = projguid;
newCFrow.TEXT_VALUE = "New value";
newCFrow.MD_PROP_UID = rowCF.MD_PROP_UID;
newCFrow.MD_PROP_ID = rowCF.MD_PROP_ID;
newCFrow.FIELD_TYPE_ENUM = rowCF.MD_PROP_TYPE_ENUM;

projectDs.ProjectCustomFields.AddProjectCustomFieldsRow(newCFrow);

//Save
Guid sessionId = Guid.NewGuid();
projectSvc.CheckOutProject(projguid, sessionId, "");
projectSvc.QueueUpdateProject(Guid.NewGuid(), sessionId, projectDs, false);
projectSvc.QueueCheckInProject(Guid.NewGuid(), projguid, true, sessionId, "");
 
C

ctd

Hi, if anyone knows the answers to the below, please help. This is urgent
and I have spent sleepless nights trying to find the solution.

1. How do I assign custom field value to a project thru PSI programming ?
2. From PWA Proposal/Activity screen, I was able to create a new project and
assign custom field values. The project was saved in RDB table
"MSP_EpmProject_UserView" with my custom field values. But how come my new
project doesn't show up on the project center screen ?

Thanks much.

ctd said:
Hello,
Using PSI, I'm creating a new project with assigned custom fields values.
My project was saved and published; however its custom fields values are just
blank, somehow they are not saved along with the project. My custom fields
are all pre-existing.

I excerpt the following from my code, hope someone can tell me what I am
missing here. I need to be able to display both the project and its custom
fields values in PWA project center. Thanks in advance.

// Create the project.
ProjectWS.ProjectDataSet.ProjectRow projectRow =
projectDs.Project.NewProjectRow();

projectRow.PROJ_UID = projguid;
projectRow.PROJ_NAME = ProjectName;
projectRow.CREATED_DATE = DateTime.Now.Date;
projectRow.PROJ_TYPE = (int)PSLib.Project.ProjectType.Project;
projectDs.Project.AddProjectRow(projectRow);

// Save the project to the database.
jobId = Guid.NewGuid();
projectSvc.QueueCreateProject(jobId, projectDs, false);
WaitForQueue(q, jobId);

// Publish the project.
jobId = Guid.NewGuid();
projectSvc.QueuePublish(jobId, projectRow.PROJ_UID, false, String.Empty);
WaitForQueue(q, jobId);

//Save custom fields
string strCustField = "Department";
mycustomDS = mycustom.ReadCustomFieldsByEntity(
new
Guid(PSLib.EntityCollection.Entities.ProjectEntity.UniqueId.ToString()));

DataView dataview = new DataView(mycustomDS.CustomFields);
dataview.RowFilter = mycustomDS.CustomFields.MD_PROP_NAMEColumn.ColumnName +
" = '" + strCustField + "'";

CustomFieldWS.CustomFieldDataSet.CustomFieldsRow rowCF =

(CustomFieldWS.CustomFieldDataSet.CustomFieldsRow)dataview[0].Row;

//Create a new custom field row
ProjectWS.ProjectDataSet.ProjectCustomFieldsRow newCFrow =
projectDs.ProjectCustomFields.NewProjectCustomFieldsRow();

//Setup the custom field
newCFrow.CUSTOM_FIELD_UID = Guid.NewGuid();
newCFrow.PROJ_UID = projguid;
newCFrow.TEXT_VALUE = "New value";
newCFrow.MD_PROP_UID = rowCF.MD_PROP_UID;
newCFrow.MD_PROP_ID = rowCF.MD_PROP_ID;
newCFrow.FIELD_TYPE_ENUM = rowCF.MD_PROP_TYPE_ENUM;

projectDs.ProjectCustomFields.AddProjectCustomFieldsRow(newCFrow);

//Save
Guid sessionId = Guid.NewGuid();
projectSvc.CheckOutProject(projguid, sessionId, "");
projectSvc.QueueUpdateProject(Guid.NewGuid(), sessionId, projectDs, false);
projectSvc.QueueCheckInProject(Guid.NewGuid(), projguid, true, sessionId, "");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top