Share via


Custom CRUD forms break when list schema changes

Symptom

A customer has a list with custom New, Edit and Display .aspx forms. The customer later changes the name of a column or removes a column. This changes in the list schema, then you get an error that there is something wrong with the query the next time you try to open the forms to edit them.

Cause

I believe the schema change invalidates the embedded query in the .aspx pages.

Solution

Create new temporary New, Edit and Display forms. Scroll to the <DataSources> element and copy it. Paste it in the corresponding section in the original New, Edit and Display Forms. Save the web pages. The new data query should work.

 

 <DataSources>
 <SharePoint:SPDataSource runat="server" DataSourceMode="ListItem" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Issue&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" UseServerDataFormat="True"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://TheSite" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{18873E6C-FF3E-4534-8055-23FAE05DEAAC}" Name="ListID"></WebPartPages:DataFormParameter>
 </SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://TheSite" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{18873E6C-FF3E-4534-8055-23FAE05DEAAC}" Name="ListID"></WebPartPages:DataFormParameter>
 </UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://TheSite" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{18873E6C-FF3E-4534-8055-23FAE05DEAAC}" Name="ListID"></WebPartPages:DataFormParameter>
 </InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://TheSite" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{18873E6C-FF3E-4534-8055-23FAE05DEAAC}" Name="ListID"></WebPartPages:DataFormParameter>
 </DeleteParameters>
 </SharePoint:SPDataSource>
 </DataSources>