【发布时间】:2009-08-17 20:59:19
【问题描述】:
我正在使用 SharePoint 服务器,并尝试以编程方式将服务请求添加到 Microsoft 的呼叫中心应用程序模板。到目前为止,我取得了相当不错的成功。我可以为指定的客户添加呼叫并分配特定的支持技术:
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 中填充了这两列,现在我想检索该数据,以便可以在我发布的代码 sn-p 中使用它来为调用分配正确的类别/软件等。我无法在代码中获得列表,我尝试过使用item["Software"]、site.Lists["Software"] 和其他几个,但到目前为止我想出的只是null。
谁能指出我正确的方向?谢谢!
【问题讨论】:
标签: c# sharepoint