ClientContext API를 통해 선택 필드에 값을 추가하십시오
-
09-12-2019 - |
문제
문서 라이브러리의 선택 필드에 값을 추가하고 선택하고 싶습니다.내가 기억하는 것보다 분명히 더 까다 롭다.
이런 일을하고 있지만 작동하지 않습니다.목록보기의 필드에 값이 추가되지만 선택 컬럼에는 추가되지 않습니다.
ClientContext ctx = new ClientContext("http://mymachine");
Web currentWeb = ctx.Web;
ctx.Load(currentWeb);
ctx.ExecuteQuery();
SP.List list = ctx.Web.Lists.GetByTitle("Doclib");
ctx.Load(list);
ctx.ExecuteQuery();
ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items);
ctx.ExecuteQuery();
foreach (ListItem listItem in items)
{
ctx.Load(listItem.File);
ctx.ExecuteQuery();
if (listItem.File.Name.Equals(fileName))
{
var processValue = "A Value";
listItem["MetaProcess"] = processValue;
//SP.FieldChoice itemType = ctx.CastTo<SP.FieldChoice>(list.Fields.GetByTitle("MetaProcess"));
//itemType.Choices = new[] { "Agenda", "Agreement", "Full text", "Minutes", "News Item", "Reference" };
//itemType.Update();
//ctx.ExecuteQuery();
}
listItem.Update();
}
ctx.ExecuteQuery();
. 해결책
SharePoint 용 Camelot .NET 커넥터를 사용하여 다른 경로에서 작동하도록 선택했습니다.
다른 팁
다음은 나를 위해 일합니다.
calendarDropDown = (DropDownList)TemplateContainer.FindControl("calendarDropDown");
if (ControlMode == SPControlMode.New || ControlMode == SPControlMode.Edit)
{
SPWeb currentWeb = SPContext.Current.Web;
SPListCollection lists = currentWeb.Lists;
foreach (SPList list in lists)
{
if (list.BaseTemplate == SPListTemplateType.Events)
{
calendarDropDown.Items.Add(list.Title);
}
}
}
. 제휴하지 않습니다 sharepoint.stackexchange