开发者

Trouble with SPFieldLinkCollection.Reorder: Isn't working as documented

开发者 https://www.devze.com 2022-12-12 18:21 出处:网络
I am working with a custom list I\'ve built in SharePoint.I have a feature which has an event handler that kicks off when the feature is activated.That event handler calls (I can debug and watch it ex

I am working with a custom list I've built in SharePoint. I have a feature which has an event handler that kicks off when the feature is activated. That event handler calls (I can debug and watch it execute) the following function:

I'm intending that the function behaves as described here.

private void OrderFields(SPWeb web)
{
   // This works fine: I get the expected SPContentType object
   // There is only 1 SPContentType in ContentTypes
   SPContentType contentType = web.Lists[TASK_LIST_NAME].ContentTypes[0];

   contentType.FieldLinks.Reo开发者_如何转开发rder(new string[4]
   {
      "Field1",
      "Field2",
      "Field3",
      "Field4"
   });

   contentType.Update();
}

The function that calls OrderFields calls web.Update(); as well.

Unfortunately, the reorder call does not reorder my fields on my form. Am I missing something? Can anyone suggest any tricks I might try?


The problem was with my field names.

I had two lookups that I'd programmatically created earlier in the execution of the event handler. These lookups' internal names vary significantly from the "Field1" and "Field2" names I'd given them in the Name and StaticName parameters of my CAML definition.

Instead, the internal name seems to be composed of the Display Name, spaces replaced by "0020", and truncated to a length of 32 characters.

0

精彩评论

暂无评论...
验证码 换一张
取 消