Placing CompositeFields for multiple list items on one form doesn't work as expected
Question
In a workflow task, in custom edit form, i use CompositeField
to render relevant fields current task item and for workflow item by setting a different context for CompositeField
.
However if i put Task List item field first, it will render only task list item fields, leaving workflow item fields with some example value like ["Title" field value]
I investigated that its actually FormField
control that CompositeField
uses to display value is guilty.
Below you can see code i use to render the workflow item field and output it provides.
<SharePoint:CompositeField ID="TitleField" FieldName="Title" ControlMode="Display" runat="server" />
SPContext workflowItemContext = SPContext.GetContext(HttpContext.Current, this.WorkflowItem.ID, this.WorkflowItem.ParentList.ID, SPContext.Current.Web);
this.TitleField.ItemContext = workflowItemContext;
Note that before rendering this control, i have other CompositeField
s that render value correctly for task item. The value says something like: ["Title" field value]
But if i change ControlMode="Edit"
, it displays field value.
What's the problem and how to get CompositeField
to display correct value not some example value at in Display mode along with other CompositeField
s with different context?
Note: I use SharePoint 2007
La solution
I have exactly same problem in sharepoint foundation 2010. So far i think it is bug in sharepoint. FormFields some how changes listid and itemid in contextes of other controls when Formfield is rendered. Note that this happens only when it rendered, so if you put two formfields on one page but one of them have visible attribute=false, other formfield will be shown correctly. I use multiview to get round this problem: i put field from different elements on different view and navigate between them with asp menu. So technically i have all fields on one page, but on differnet 'tabs'.