QueueUpdateProject doesn't seem to work for custom fields
-
Tuesday, 27 July 2010 8:42 AM
Hi,
I have a project which I've changed some tasks in it and some of their custom fields. I'm using the
QueueUpdateProject method to reflect these changes back to the server and then check-in the project using
QueueCheckInProject. No exception or error arose by these methods but I don't see the changes reflecting in the project server (using project proffesional).
For each custom field that I change I call the AcceptChanges method eitherwise the QueueUpdateProject throws an exception "CustomFieldRequiredValueNotProvided" (all fields are not-required). If I do use the acceptchanges method then no change is done in the server.
Id
All Replies
-
Wednesday, 28 July 2010 7:24 AM
Hi,
I think that you might have a problem saving the data when the Custom field type is text. See this example where you have to take into account when you save this type of custom field.
static public int AddTaskCFs(Guid projUid, Guid taskUid, wsProject.ProjectDataSet.TaskCustomFieldsDataTable dtTaskCFs, wsProject.ProjectDataSet.TaskCustomFieldsDataTable dtTaskUpdateCFs, bool leafOnly) { int count = 0; foreach (wsCustomFields.CustomFieldDataSet.CustomFieldsRow rowCF in dsTaskCustomFields.CustomFields.Rows) { if (!rowCF.IsMD_PROP_FORMULANull()) continue; dtTaskCFs.DefaultView.RowFilter = "TASK_UID = '" + taskUid.ToString() + "' AND MD_PROP_UID = '" + rowCF.MD_PROP_UID + "'"; if (dtTaskCFs.DefaultView.Count == 0) { // Add the custom field. wsProject.ProjectDataSet.TaskCustomFieldsRow rowTaskCF = dtTaskUpdateCFs.NewTaskCustomFieldsRow(); rowTaskCF.MD_PROP_UID = rowCF.MD_PROP_UID; rowTaskCF.PROJ_UID = projUid; rowTaskCF.TASK_UID = taskUid; rowTaskCF.CUSTOM_FIELD_UID = Guid.NewGuid(); switch (rowCF.MD_PROP_TYPE_ENUM) { case (byte)PSLib.CustomField.Type.TEXT://you need to find the text values in the LookUpTable if (!rowCF.IsMD_LOOKUP_TABLE_UIDNull()) { DataRowView rowLTT = FindLookupTableTree(rowCF.MD_LOOKUP_TABLE_UID); DataRowView rowLTTLeaf = rowLTT; if (rowLTT == null) continue; if (LeafOnly(leafOnly, rowCF)) { while (rowLTT != null) { rowLTTLeaf = rowLTT; rowLTT = FindChildLookupTableTree((Guid)rowLTT["LT_STRUCT_UID"]); } } rowTaskCF.CODE_VALUE = (Guid)rowLTTLeaf["LT_STRUCT_UID"]; } else //the text value can be anything { rowTaskCF.TEXT_VALUE = "Created by Data Population"; } break; [...] } dtTaskUpdateCFs.AddTaskCustomFieldsRow(rowTaskCF); count++; } } return count; }
Hope this help
Jorge
[ The ultimate for Project Server 2007 || http://www.projecttimesheet.com/about-en.php ]- Proposed As Answer by Brian Smith - MSFTMicrosoft Employee, Moderator Thursday, 29 July 2010 7:37 PM
-
Wednesday, 28 July 2010 2:43 PMOwner
And you shouldn't use AcceptChanges ID - see http://blogs.msdn.com/b/brismith/archive/2007/01/09/working-with-project-server-datasets-and-the-web-services.aspx. Accepting changes before updating means that the PSI will not see the change. You may also need to use QueueAddToProject when adding rather than changing data.
Best regards,
Brian.
Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page -
Wednesday, 4 August 2010 6:43 PM
Jorge,
Thank you, but it wasn't helpful. I didn't have lookup values in my custom fields, so this wasn' the problem. Unfortunately I still don't know what is the problem. I use both methods QueueAddToProject and QueueUpdateProject, the first runs ok but the second raises a faultexception with a very vague description - generalqueueexception. I've tried extracting the PSError out of it but it is always null so I have no clue what is causing the problem.
BTW - about the lookup values - where do I get them from? I can find the table (name and GUID the belong to and their code_value but can't find their actual value.
-
Wednesday, 4 August 2010 9:08 PMOwner
Hi I D,
The SDK article on creating a hierarchical lookup table may help you understand the data structures http://msdn.microsoft.com/en-us/library/ms486189(office.12).aspx and my blog posting on the different types of custom fields might help too. http://blogs.msdn.com/b/brismith/archive/2007/12/06/setting-custom-field-values-using-the-psi.aspx. From your original posting it would appear you are just trying to add or update task level custom fields. Are these text fields? You have already said you are not using lookup tables.
Best regards,
Brian.
Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page -
Thursday, 5 August 2010 7:35 PM
Brian,
Thanks for the answer I found the problem. For my reason I used the same dataset to hold new rows and updated rows and just before updating the project I created an addtional dataset with the new rows, while removing them from the original one. This caused the problem.
about the lookup table, it is a different issue that I stumble upon.
Id- Marked As Answer by Brian Smith - MSFTMicrosoft Employee, Moderator Monday, 9 August 2010 10:05 PM