F
f.lange90
Hello,
i declared my Customfield as a Process so that i can make it visible via the WebApp.
The Problem is that i get the following Error if i am trying to Update through
QueueUpdateProject
"ProjectServerError(s) LastError=CustomFieldInvalidUID Instructions: Passthis into PSClientError constructor to access all error Information"
If my CustomField is declared as a Project it runs without Error.
Here is my Code.
ProjectDataSet projectList = projectSvc.ReadProjectList();
//Projektinformationen lesen
Guid myProjectUid = projectList.Project[0].PROJ_UID;
myProjectUid = new Guid("44F93319-E213-4CBD-A262-7FFBBF399007");
ProjectDataSet myProject = projectSvc.ReadProject(myProjectUid, DataStoreEnum.WorkingStore);
//Hole Definition der Custom Field
CustomFieldDataSet fieldDefs = customfieldSvc.ReadCustomFields(string.Empty, false);
//Beispiel Custom Field
string cfName = "Penta-Fortschritt";
string cfValue = "15%";
Guid cfId = new Guid("3b996f3d-9b0a-475b-a91b-771547a739b9");
//Indikator ob Feld bereits vorhanden
bool customFieldFound = false;
//Gehe alle Felder durch und prüfe ob Feld vorhanden
foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow
in myProject.ProjectCustomFields)
{
//Wenn Feld exisitiert, updaten
if (cfRow.MD_PROP_UID == cfId)
{
//Updaten
cfRow.TEXT_VALUE = cfValue;
customFieldFound = true;
}
}
//Prüfe ob Feld gefunden wurde
if (!customFieldFound)
{
//Neue Zeile erstellen, wenn Feld nicht vorhanden
ProjectDataSet.ProjectCustomFieldsRow cfRow = myProject.ProjectCustomFields.NewProjectCustomFieldsRow();
//Alles auf Null setzen
cfRow.SetNUM_VALUENull();
cfRow.SetFLAG_VALUENull();
cfRow.SetDUR_VALUENull();
cfRow.SetDUR_FMTNull();
cfRow.SetDATE_VALUENull();
cfRow.SetCODE_VALUENull();
cfRow.SetTEXT_VALUENull();
//Allgemeine Parameter
cfRow.MD_PROP_UID = cfId; //custom field enterprise id
cfRow.CUSTOM_FIELD_UID = Guid.NewGuid();
cfRow.PROJ_UID = myProjectUid; //current project id
//Wert hinzufügen
cfRow.FIELD_TYPE_ENUM = 21;
cfRow.TEXT_VALUE = Convert.ToString(cfValue); //our test value
//Die Reihe dem Dataset hinzufügen
myProject.ProjectCustomFields.AddProjectCustomFieldsRow(cfRow);
}
//ID erstellen
Guid sessionId = Guid.NewGuid();
Guid jobId = Guid.NewGuid();
//Auschecken
projectSvc.CheckOutProject(myProjectUid, sessionId,
"custom field update checkout");
//Updaten
bool validateOnly = false;
projectSvc.QueueUpdateProject (jobId, sessionId,
myProject, validateOnly);
//Warten
WaitForJob(jobId);
//JobID erstellen
jobId = Guid.NewGuid();
//Einchecken
bool force = false;
string sessionDescription = "updated custom fields";
projectSvc.QueueCheckInProject(jobId, myProjectUid,
force, sessionId, sessionDescription);
//Warten
WaitForJob(jobId);
}
i declared my Customfield as a Process so that i can make it visible via the WebApp.
The Problem is that i get the following Error if i am trying to Update through
QueueUpdateProject
"ProjectServerError(s) LastError=CustomFieldInvalidUID Instructions: Passthis into PSClientError constructor to access all error Information"
If my CustomField is declared as a Project it runs without Error.
Here is my Code.
ProjectDataSet projectList = projectSvc.ReadProjectList();
//Projektinformationen lesen
Guid myProjectUid = projectList.Project[0].PROJ_UID;
myProjectUid = new Guid("44F93319-E213-4CBD-A262-7FFBBF399007");
ProjectDataSet myProject = projectSvc.ReadProject(myProjectUid, DataStoreEnum.WorkingStore);
//Hole Definition der Custom Field
CustomFieldDataSet fieldDefs = customfieldSvc.ReadCustomFields(string.Empty, false);
//Beispiel Custom Field
string cfName = "Penta-Fortschritt";
string cfValue = "15%";
Guid cfId = new Guid("3b996f3d-9b0a-475b-a91b-771547a739b9");
//Indikator ob Feld bereits vorhanden
bool customFieldFound = false;
//Gehe alle Felder durch und prüfe ob Feld vorhanden
foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow
in myProject.ProjectCustomFields)
{
//Wenn Feld exisitiert, updaten
if (cfRow.MD_PROP_UID == cfId)
{
//Updaten
cfRow.TEXT_VALUE = cfValue;
customFieldFound = true;
}
}
//Prüfe ob Feld gefunden wurde
if (!customFieldFound)
{
//Neue Zeile erstellen, wenn Feld nicht vorhanden
ProjectDataSet.ProjectCustomFieldsRow cfRow = myProject.ProjectCustomFields.NewProjectCustomFieldsRow();
//Alles auf Null setzen
cfRow.SetNUM_VALUENull();
cfRow.SetFLAG_VALUENull();
cfRow.SetDUR_VALUENull();
cfRow.SetDUR_FMTNull();
cfRow.SetDATE_VALUENull();
cfRow.SetCODE_VALUENull();
cfRow.SetTEXT_VALUENull();
//Allgemeine Parameter
cfRow.MD_PROP_UID = cfId; //custom field enterprise id
cfRow.CUSTOM_FIELD_UID = Guid.NewGuid();
cfRow.PROJ_UID = myProjectUid; //current project id
//Wert hinzufügen
cfRow.FIELD_TYPE_ENUM = 21;
cfRow.TEXT_VALUE = Convert.ToString(cfValue); //our test value
//Die Reihe dem Dataset hinzufügen
myProject.ProjectCustomFields.AddProjectCustomFieldsRow(cfRow);
}
//ID erstellen
Guid sessionId = Guid.NewGuid();
Guid jobId = Guid.NewGuid();
//Auschecken
projectSvc.CheckOutProject(myProjectUid, sessionId,
"custom field update checkout");
//Updaten
bool validateOnly = false;
projectSvc.QueueUpdateProject (jobId, sessionId,
myProject, validateOnly);
//Warten
WaitForJob(jobId);
//JobID erstellen
jobId = Guid.NewGuid();
//Einchecken
bool force = false;
string sessionDescription = "updated custom fields";
projectSvc.QueueCheckInProject(jobId, myProjectUid,
force, sessionId, sessionDescription);
//Warten
WaitForJob(jobId);
}