Could it be that you've set the boolean contentTypeAssociated = true before your final if (!contentTypeAssociated) statement?
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Trevor Andrew Sent: Monday, 4 August 2008 2:54 PM To: [email protected] Subject: [OzMOSS] RE: Associating Content Type with Task List Hi All, I'm having some difficulties getting newly released and newly revised versions of existing content types associated with a task list correctly. The code I'm currently using, which is running in the context of a workflow which is responsible for creating these custom tasks, is below: if (!this.workflowProperties.TaskList.ContentTypesEnabled) { this.workflowProperties.TaskList.ContentTypesEnabled = true; } SPContentTypeId newContentTypeId = new SPContentTypeId(contentTypeIDString); SPContentType newContentType = workflowProperties.Site.RootWeb.ContentTypes[newContentTypeId]; bool contentTypeAssociated = false; foreach (SPContentType contentType in workflowProperties.TaskList.ContentTypes) { if (contentType.Name == awaitingResponseReviewTaskContentType.Name) { contentTypeAssociated = true; break; } } if (!contentTypeAssociated) { workflowProperties.TaskList.ContentTypes.Add(awaitingResponseReviewTaskC ontentType); } The steps I follow are below: * Delete all tasks from the task list * Dissociate the custom task content type from the task list * Delete all site columns associated with the custom task content types on the task list * Deploy the new content type as a feature, both site columns and content types by o Deactivating custom task content types feature o Uninstalling custom task content types feature o Deactivating custom site columns feature o Uninstalling custom site columns feature o Installing custom site columns feature o Activating custom site columns feature o Installing custom task content types feature o Activating custom task content types feature o Usual IISRESET etc * During the running of a workflow, that creates these tasks, the code above runs and re-associates what should be the new content type. What I seem to be observing however is that the programmatic association is re-associating what appears to be the old content type, without the changes. If after doing the deployment of the content type I re-associate then with the task list through the task list setting UI, the new content type gets associated correctly ... very odd Can anyone see where I'm going wrong? Is the code above flawed? Kind Regards, Trevor Andrew ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com ____________________________________________________________________________ This e-mail is intended for the use of the addressed recipient(s) only and may contain confidential and privileged information. If you have received this message in error, please delete the message and any attachments and copies immediately; and notify the sender by return e-mail. Any views expressed in this message or any attachments are those of the individual sender and do not necessarily represent the corporate opinion of the Catholic Education Office (CEO), Sydney. The CEO Privacy Policy is located at http://www.ceo.syd.catholic.edu.au ____________________________________________________________________________ ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com
