SharePoint 서버를 가지고 놀고있어 프로그래밍 방식으로 Microsoft의 콜 센터 응용 프로그램 템플릿에 서비스 요청을 추가하려고합니다. 지금까지, 나는 꽤 좋은 성공을했습니다. 나는 특정 고객을 위해 전화를 추가하고 특정 지원 기술 지정할 수 있습니다 : 나는 모두 채워SharePoint 필드 선택 열의 모든 항목 검색
: 내가 기본 목록에 두 개의 사용자 정의 열 (카테고리, 소프트웨어)를 추가
private enum FieldNames
{
[EnumExtension.Value("Service Request")]
ServiceRequest,
[EnumExtension.Value("Customer")]
Customer,
[EnumExtension.Value("Service Representative")]
ServiceRepresentative,
[EnumExtension.Value("Assigned To")]
AssignedTo,
[EnumExtension.Value("Software")]
Software,
[EnumExtension.Value("Category")]
Category
}
private void CreateServiceCall(string serviceCallTitle, string customerName, string serviceRep)
{
SPSite allSites = new SPSite(siteURL);
SPWeb site = allSites.AllWebs[siteName];
SPListItemCollection requestsList = site.Lists[serviceRequests].Items;
SPListItem item = requestsList.Add();
SPFieldLookup customerLookup = item.Fields[FieldNames.Customer.Value()] as SPFieldLookup;
item[FieldNames.ServiceRequest.Value()] = serviceCallTitle;
if (customerLookup != null)
{
using (SPWeb lookupWeb = allSites.OpenWeb(customerLookup.LookupWebId))
{
SPList lookupList = lookupWeb.Lists.GetList(new Guid(customerLookup.LookupList), false);
foreach (SPListItem listItem in lookupList.Items)
{
if (listItem[customerLookup.LookupField].ToString() != customerName) continue;
item[FieldNames.Customer.Value()] = new SPFieldLookupValue(listItem.ID, customerName);
break;
}
}
}
SPUserCollection userCollection = site.SiteUsers;
if (userCollection != null)
{
foreach (SPUser user in userCollection)
{
if (user.Name != serviceRep) continue;
item[FieldNames.AssignedTo.Value()] = user;
break;
}
}
item.Update();
site.Close();
allSites.Close();
}
을 이제 SharePoint의 내부에서 이러한 열을 가져 와서 해당 데이터를 검색하여 적절한 카테고리/소프트웨어 등을 할당하도록 게시 한 코드 스 니펫에서 사용할 수 있습니다. 코드에서 목록을 가져올 수 없었으므로 item["Software"]
, site.Lists["Software"]
및 몇 가지 다른 문자를 사용해 보았습니다. 그러나 지금까지 모두 내가 생각해 낸 것은 null
입니다.
누구나 나를 올바른 방향으로 안내 할 수 있습니까? 감사! 당신은 필드에 값을 설정해야하는 경우
SPFieldMultiChoice software = item.Fields[FieldNames.Software.Value()] as SPFieldMultiChoice;
StringCollection softwareChoices = software.Choices;
에서, SPFieldMultiChoiceValue
유형을 사용 :
완벽한, 감사합니다! – Anders
이 예제는'SPListItem'에서'SPFieldMultiChoice' 객체를 가져 오는 방법을 보여줍니다 - 당신이'SPList'에서이 객체를 얻을 수 있다는 것에 주목하십시오. List를 얻은 후에 Choices 속성에 접근하기 때문에 더 유용했습니다 참조,하지만 전에 목록의 항목 iterating 시작했다. 예제에서 'item.Fields'가 액세스되는 것과 정확히 똑같이'SPList.Fields' 속성에 액세스하십시오. – CBono