Following on from my posting on adding custom fields http://blogs.msdn.com/b/brismith/archive/2010/08/25/project-server-adding-custom-fields-to-projects-and-tasks-using-the-psi.aspx I had a few questions on changing fields – or deleting them. So here are a couple of short samples that follow the same code from the previous sample and show how to update a task level custom field and also to delete a custom field. In my sample I have hard-coded the GUID for my project and for my custom field. And my project just has one task, so in the real world you would also need to ensure you were acting on the right task – otherwise my code would update every occurrence of that custom field for every task – or delete every occurrence… Also when I am creating these samples I usually start from the LoginDemo sample and just add buttons to do the stuff I am playing with. So the previous sample created a project – these two just update the CF or delete it. Obviously I am updating a Text custom field at the task level – if you are updating another custom field type you would need to change the TEXT_VALUE as appropriate. Also be a good idea to see if the row exists before updating or deleting it – but I’ll leave that to you. This was created with 2007 but the logic would be the same in 2010.
private void btnUpdateCF_Click(object sender, EventArgs e) { Guid taskTextGuid = new Guid("30665299-bc21-4c51-b954-220d407ba47e"); Guid projectId = new Guid("4c1cef33-4810-4159-b2e1-db15ea19a28b"); WebSvcProject.ProjectDataSet projectDs = project.ReadProject(projectId, WebSvcProject.DataStoreEnum.WorkingStore); foreach (WebSvcProject.ProjectDataSet.TaskCustomFieldsRow cfRow in projectDs.TaskCustomFields) { if (cfRow.MD_PROP_UID == taskTextGuid) { cfRow.TEXT_VALUE = "Updated Value"; } } Guid sessionUid = Guid.NewGuid(); project.CheckOutProject(projectId, sessionUid, "Updating CF"); Guid jobUid = Guid.NewGuid(); project.QueueUpdateProject(jobUid, sessionUid, projectDs, false); jobUid = Guid.NewGuid(); project.QueueCheckInProject(jobUid, projectId, false, sessionUid, "Updating CF"); }
private void btnDeleteCF_Click(object sender, EventArgs e) { Guid taskTextGuid = new Guid("30665299-bc21-4c51-b954-220d407ba47e"); Guid projectId = new Guid("4c1cef33-4810-4159-b2e1-db15ea19a28b"); WebSvcProject.ProjectDataSet projectDs = project.ReadProject(projectId, WebSvcProject.DataStoreEnum.WorkingStore); foreach (WebSvcProject.ProjectDataSet.TaskCustomFieldsRow cfRow in projectDs.TaskCustomFields) { if (cfRow.MD_PROP_UID == taskTextGuid) { cfRow.Delete(); } } Guid sessionUid = Guid.NewGuid(); project.CheckOutProject(projectId, sessionUid, "Updating CF"); Guid jobUid = Guid.NewGuid(); project.QueueUpdateProject(jobUid, sessionUid, projectDs, false); jobUid = Guid.NewGuid(); project.QueueCheckInProject(jobUid, projectId, false, sessionUid, "Updating CF"); }
*** Update *** 11/18/2010 - The issues have now been resolved and the links to the revised updates are now available. The KB number is unchanged, but the Revision Number on the article is 2.0 and the version of the patch is 14.0.5128.5003. Sorry for any inconvenience caused.
***Update*** Please see the latest information on potential issues with the October CU at http://blogs.technet.com/b/projectadministration/archive/2010/11/08/critical-information-about-the-sharepoint-server-2010-october-cumulative-update.aspx
The October Cumulative Update for both the 2007 and 2010 versions of Project, Project Server and SharePoint Server is now available. See the posting over at http://blogs.technet.com/b/projectadministration/archive/2010/10/27/microsoft-project-server-and-sharepoint-2007-and-2010-october-cu-2010-are-live.aspx for the full details, and don’t forget the Webcast on November 9th with Adrian Jenkins and me.
Don’t forget that SP2 is now (since the August CU) a requirement for the 2007 cumulative updates. Also be sure to visit the Updates section of the new TechNet resource center at http://technet.microsoft.com/en-us/projectserver/gg176680.aspx.
I will be updating my cumulative cumulative update blog posting with the version numbers from the October 2010 CU shortly.
Yes, they are letting me out! I get to go to Momentum and will be presenting in the Technical Track. See Christophe’s post for full details - http://blogs.msdn.com/b/chrisfie/archive/2010/10/05/microsoft-project-momentum-2010-emea-are-you-going-the-project-team-will.aspx.
Hope to meet some of you there.
Thanks to Guillaume from TPG for pointing this out, and for Rob for digging out the answer. Our cumulative update for August was considerably smaller than the one for June. How come? Its cumulative isn’t it? Doesn’t it just get bigger? Well the change that happened with the August release – and all future Project Server 2007 and MOSS 2007 cumulative updates is that they require SP2. Another way this requirement may show up is if you try to load the CU and then you get a message saying “There are no products affected by this package installed on this system”. This could mean you have loaded previous CUs, but haven’t yet loaded SP2.
Another reason you may get this is if you are trying to install the x86 version of a CU and you actually have the x64 product installed. So check carefully.