例: 10 のサイトがあり、すべてのサイトに 5 つのリストがあります。サイト 1 から、listX に 1 つの項目を追加すると、ID は「1」になり、4 番目のサブサイトの listB に別の項目を作成すると、ID は「2」になります... ?
すべてのリスト項目追加イベントでこれを更新する必要がありますか? また、最新のIDを取得する方法は?
カスタムフォームでこのコードを試してみましたが、うまくいきましたが、これにより並行性の問題が発生する可能性があると考えています
public static void ID()
{
if ((field.InternalName.Equals("Field1")))
{
{
string template;
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb web = site.RootWeb)
{
template = web.Properties["eydtemplate"].ToString();
}
}
if ("eydadvisory" == template)
{
SPListItemCollection items = _currentList.Items;
if (_currentList.ItemCount == 0)
{
webControl.Field.DefaultValue = (1).ToString();
}
else
{
SPQuery query = new SPQuery();
query.RowLimit = 1;
query.Query = " <OrderBy><FieldRef Name='" + field.InternalName + "' Ascending='FALSE' /></OrderBy>";
webControl.Field.DefaultValue = (Convert.ToInt64(_currentList.GetItems(query).Cast<SPListItem>().FirstOrDefault()[field.InternalName]) + 1).ToString();
}
}
}