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, "");
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, "");