Answered by:
Update Enterprise Custom Field

Question
-
I need to update Enterprise Custom field from code behind. But, my custom field can contain only values from lookup table.
Custom Field Name: "Status"
Values from lookup that Custom Field can have: "S1", "S2", "S3".
Custom Field "Status" has value S1 and I need to change it to S2. How?
This how I get to my "Status" field
ProjectDataSet tProj = svcProject.ReadProjectEntities(projectUid, 32, DataStoreEnum.WorkingStore);
CustomFieldDataSet customFieldsDs = svcCustomFields.ReadCustomFields("", false);
string guid = "";
CustomFieldDataSet.CustomFieldsDataTable cfDataTable = customFieldsDs.CustomFields;
for (int i = 0; i < cfDataTable.Count; i++)
{
if (cfDataTable[i].MD_PROP_NAME == "Current Status")
{
Guid a = cfDataTable[i].MD_PROP_UID;
guid = a.ToString();
}
}
string tCurrentStatusStr = tCurrentStatusGuid.ToString();
DataRow[] cfRows = tProj.ProjectCustomFields.Select(tProj.ProjectCustomFields.MD_PROP_UIDColumn.ColumnName + " = '" + guid + "'");
string Lt_guid = cfRows[0].ItemArray[8].ToString();In Lt_guid variable is guid of value from lookup table. How do I change that guid. Am I on the right track here?
- Edited by SPManiac Friday, December 7, 2012 5:03 PM
Friday, December 7, 2012 5:02 PM
Answers
-
Hi there--
use CustomFieldsWS.CustomFieldDataSet.CustomFieldsRow cfRow to loop through the data:
Mapping: In CfRow
MD_PROP_UID as the CFuid
MD_LOOKUP_TABLE_UID as the Lookup table Uid
MD_PROP_DEFAULT_VALUE as Default value from LTFor the S1 value, You get the LT_VALUE_TEXT from lookup table web service & get the CODE_VALUE, For S2, You get the code_value & set it in projectCustomFields table of projectadtaset.
look at the example to better understand the relationship of CF & LT.
http://msdn.microsoft.com/en-us/library/gg176849.aspxSample:
http://blogs.msdn.com/b/brismith/archive/2010/08/25/project-server-adding-custom-fields-to-projects-and-tasks-using-the-psi.aspxhttp://social.msdn.microsoft.com/Forums/sv-SE/project2010custprog/thread/7fac1952-90b8-44cb-8980-d7fa500b79f0
Hope that helps.
If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82
- Edited by Amit Khare - Project Management Consultant Monday, December 10, 2012 9:02 AM
- Proposed as answer by kodanda ram kanumuri Tuesday, December 18, 2012 9:22 AM
- Marked as answer by SPManiac Friday, February 22, 2013 3:41 PM
Monday, December 10, 2012 9:01 AM
All replies
-
Anyone?Saturday, December 8, 2012 5:27 PM
-
Hi there--
use CustomFieldsWS.CustomFieldDataSet.CustomFieldsRow cfRow to loop through the data:
Mapping: In CfRow
MD_PROP_UID as the CFuid
MD_LOOKUP_TABLE_UID as the Lookup table Uid
MD_PROP_DEFAULT_VALUE as Default value from LTFor the S1 value, You get the LT_VALUE_TEXT from lookup table web service & get the CODE_VALUE, For S2, You get the code_value & set it in projectCustomFields table of projectadtaset.
look at the example to better understand the relationship of CF & LT.
http://msdn.microsoft.com/en-us/library/gg176849.aspxSample:
http://blogs.msdn.com/b/brismith/archive/2010/08/25/project-server-adding-custom-fields-to-projects-and-tasks-using-the-psi.aspxhttp://social.msdn.microsoft.com/Forums/sv-SE/project2010custprog/thread/7fac1952-90b8-44cb-8980-d7fa500b79f0
Hope that helps.
If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82
- Edited by Amit Khare - Project Management Consultant Monday, December 10, 2012 9:02 AM
- Proposed as answer by kodanda ram kanumuri Tuesday, December 18, 2012 9:22 AM
- Marked as answer by SPManiac Friday, February 22, 2013 3:41 PM
Monday, December 10, 2012 9:01 AM