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(awaitingResponseReviewTaskConte
ntType);

                }

 

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

Reply via email to