我正在玩一个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();
}
Run Code Online (Sandbox Code Playgroud)
我在默认列表中添加了两个自定义列(类别,软件):

我在SharePoint中填充了这两个列,现在我想检索那些数据,这样我就可以在我发布的代码片段中使用它来为调用分配正确的类别/软件等.我一直没能得到在代码列表中,我一直在使用一个尝试item["Software"],site.Lists["Software"]和其他几个,但到目前为止,所有我想出的null.
任何人都能指出我正确的方向吗?谢谢!
SPFieldMultiChoice和相关领域有一个Choices属性:
SPFieldMultiChoice software = item.Fields[FieldNames.Software.Value()] as SPFieldMultiChoice;
StringCollection softwareChoices = software.Choices;
Run Code Online (Sandbox Code Playgroud)
如果需要在字段上设置值,请使用以下SPFieldMultiChoiceValue类型:
SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue();
values.Add("Choice 1");
values.Add("Choice 2");
item[FieldNames.Software.Value()] = values;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9351 次 |
| 最近记录: |