Tuesday, January 20, 2009

Sharepoint - Adding an Item to a Multi-Choice field through a Workflow

// The following code adds a Choice Item to a MultiChoice field just after a Workflow has been initiated......
// My problem with this code is that even though I've set '
spFieldMultiChoice.PushChangesToLists = false;',
// the values still propagate to other ListItem's MultiChoice Fields.

public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties
            WorkflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();

SPListItem spListItem = WorkflowProperties.Item.ListItems[0];
SPFieldMultiChoice spFieldMultiChoice = (SPFieldMultiChoice)spListItem.Fields["DropDown"];
spFieldMultiChoice.Choices.Add("Added this thru code.. " + DateTime.Now.ToString());

//
Gets or sets a Boolean value that specifies whether to propagate changes that are made in the field template to lists that implement the field.
// http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.pushchangestolists.aspx
spFieldMultiChoice.PushChangesToLists = false;
spFieldMultiChoice.Update();

1 Comments:

Blogger sanjana said...

Hey thnx for posting this...

it helped me a lot... :)

November 11, 2009 5:40 PM  

Post a Comment

Links to this post:

Create a Link

<< Home