问题标签 [splistitem]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - Programmatically created document set item is always a folder
I have a problem by creating a list item programmatically. The szenario:
2 Lists (Changes-CustomDocSet Lib, Risks-Custom Task List) with custom content types and fields
The new/edit form of the Changes List includes a DataGrid witch shows the items of the Risks list
All items, i created manually in the Risk list are shown. Now I can add additional items from the new/edit form of the Changes list using the Add button. I can insert but the item is not shown in the grid.
Risk items within new form of changes list:
Why? If i look into my Risk list, I can see the inserted item, but it is not a item, it is shown as folder type.
Add new risk item:
This is my implementation to add the item:
The List Definition only has my custom content type:
The manually created item can be found within list.Items, the programmitcally created item are always created in list.folders, but I don't know why and how to change that? I need normal items, not folders.
Manually vs. prog items:
Any idears?
UPDATE:
I already try to set the CT, without success. I now use a standard task list without custom content type, but it always created a folder instead an item.
While debugging, everything looks fine:
c# - C# - 将文件作为附件添加到 Microsoft.SharePoint.Client.ListItem (SharePoint 2010)
我没有更多的想法了。我想为 Sharepoint List 创建一个新元素并将文件添加为附件。我可以用ListItem
. 但是文件不会上传。
我尝试使用SaveBinaryDirect()
功能和AttachmentCreationInformation()
类。如果我尝试我会得到这个异常
抛出异常:System.dll 中的“System.Net.WebException”(400)
我还连接到 SharePoint Server 并查看了 Windows 日志,但什么也没找到。
在我的代码中,我添加了一个新ListItem
的lLibrary.AddItem(itemCreateInfo)
. 随着ListItem
我在 SharePoint 中创建一个新元素。此元素位于 SharePoint 文件夹中。这一切都很好。
我尝试了很多,但没有任何效果。我需要帮助,拜托!
这是我的完整代码:
编辑!:
我犯了一个大错误。Sharepoint 是 2010。所以该AttachmentFiles.Add()
功能不起作用。
我发现我必须添加服务引用并更改我的代码。可以在SharePoint 2010 - 客户端对象模型 - 将附件添加到 ListItem中找到更多信息
但现在我得到 Exception 500。这就是我尝试连接到测试 SharePoint 的原因。在那里我可以使用 Message 读取日志信息The list does not exist.
The selected page contains a list that does not exist. The list could have been deleted by another user.
我不知道必须为找到列表listName
的函数指定什么属性。AddAttachment()
我的新代码:
c# - SPListItemCollection 上的 C# Parallel.ForEach() 导致异常 (0x80010102)
在我的 ASP.NET MVC 应用程序中,我试图检索具有版本历史记录的列表中的所有项目,然后将它们转换为自定义对象。为此,我正在使用Microsoft.SharePoint
.
我最初是通过以下方式执行此操作的:
Util.GetSPItemCollectionWithHistory 方法:
GetSPObjectsWithHistory 方法:
SPObjectWithHistory 类构造函数:
这种方式代码可以工作,但在大型列表上非常慢。其中一个列表中有超过 80000 个项目SPObjectWithHistory
,由于构造函数中的逻辑,创建一个项目大约需要 0.3 秒。
为了加快这个过程,我想使用Parallel.ForEach
而不是常规的foreach
.
然后我GetSPObjectsWithHistory
的更新为:
但是,当我现在尝试运行该应用程序时,我在以下位置收到以下异常Parallel.ForEach
:
消息:发生一个或多个错误。
类型: System.AggregateException
堆栈跟踪:
在 System.Threading.Tasks.Task.ThrowIfExceptional(布尔 includeTaskCanceledExceptions)
在 System.Threading.Tasks.Task.Wait(Int32 毫秒超时,CancellationToken 取消令牌)
在 System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action'1 body, Action'2 bodyWithState, Func'4 bodyWithLocal, Func'1 localInit, Action'1 localFinally)
在 System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable'1 源,ParallelOptions 并行选项,Action'1 主体,Action'2 bodyWithState,Action'3 bodyWithStateAndIndex,Func'4 bodyWithStateAndLocal,Func'5 bodyWithEverything,Func '1 localInit, Action'1 localFinally)
在 System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable'1 源,Action'1 主体)
在 GetSPObjectsWithHistory(SPQuery 查询,List`1 过滤器)中...
内部异常:
消息:尝试在单线程模式下调用多个线程。(来自 HRESULT 的异常:0x80010102 (RPC_E_ATTEMPTED_MULTITHREAD))
类型: Microsoft.SharePoint.SPException
堆栈跟踪:
在 Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
在 Microsoft.SharePoint.Library.SPRequest.SetVar(字符串 bstrUrl,字符串 bstrName,字符串 bstrValue)
在 Microsoft.SharePoint.SPListItemVersionCollection.EnsureVersionsData()
在 Microsoft.SharePoint.SPListItemVersionCollection.get_Item(Int32 iIndex)
在构造函数中的行。
double.TryParse(spItem.Versions[0].VersionLabel, out _currentVersion);
SPObjectWithHistory
内部异常:
消息:尝试在单线程模式下调用多个线程。(来自 HRESULT 的异常:0x80010102 (RPC_E_ATTEMPTED_MULTITHREAD))
类型: System.Runtime.InteropServices.COMException
堆栈跟踪:
在 Microsoft.SharePoint.Library.SPRequestInternalClass.SetVar(字符串 bstrUrl,字符串 bstrName,字符串 bstrValue)
在 Microsoft.SharePoint.Library.SPRequest.SetVar(字符串 bstrUrl,字符串 bstrName,字符串 bstrValue)
会有人知道我如何让我的代码工作吗?
提前致谢!
c# - 如何使用 .Net 更新 Sharepoint ListItem?
基本上我查询 Sharepoint 并获取 ListItems 列表。我遍历列表并检查是否需要从外部数据库更新项目(该代码不存在)
这是我正在运行的一段代码,它不会更新 Sharepoint ListItem。我什至尝试了不同的凭据无济于事。
sharepoint - 将项目添加到列表时,我收到错误 Invalid data has been used to update the list item。您尝试更新的字段可能是只读的
我正在使用客户端对象模型来更新 SharePoint 上的列表。
列表很简单,只有 3 列([Title]、[Author]、[Year Published])
【标题】为默认添加的标准栏,
[作者] 是我自己的列,它是一个字符串字段(它不指向用户,它只是纯文本)
和 [发布年份] 发布是一个数字。
所有字段都标记为必填项。
我得到例外book.Update();
无效数据已用于更新列表项。您尝试更新的字段可能是只读的。
我查看了我在网上找到的所有内容,但没有找到任何答案。请指教。
c# - 如何从 UserControl.ascx.cs SharePoint 访问解决方案列表项
这是我的 UserControl.ascx.cs 部分类
我不能在这个类中使用“ListItem”。
所以;
如何从部分类访问我的列表项?
如何在 ascx 中使用 boss 变量?
我想要这个,因为我想在 ascx 文件中比较 currentUser.ID 和 boss.User.ID 并在模板上显示特殊字段。
提前致谢
c# - Sharepoint List 检索大数据 C#
TryGetList实际上是检索整个列表还是像IQueryable一样工作?如果我的列表有 100 万条记录,那么以下方法对吗?
c# - 如何更改 SPListItem.Level 属性?
我想以编程方式更改 SPlistitem.Level 属性。但现在,我创建程序。SPlistitem.Level 属性是只读属性。我也尝试使用 SPFile.Level 属性。但现在结果是一样的。
所以任何人都请如何以编程方式更改 SPlistItem.Level 属性。
感谢关注。
c# - 如何以编程方式将 SPListItem 从源列表移动到目标列表(到列表的特定文件夹中)?
我是 SharePoint 的新手(我正在使用 SharePoint 2013),但遇到以下问题:
我在源网站上有一个源列表(一个SPList),我必须将其项目移动到目标网站上的一个目标列表(另一个SPList)。
所以基本上我必须将一些SPListItem从一个列表移动到两个不同网站上的另一个。
更复杂的是,目标列表包含基于迁移项目上的日期字段的文件夹(例如:如果日期是:2019/05/28,它将在目标列表中创建以下文件夹,如下所示 2019 - > 05 --> 28 必须放置此SPListItem)。
我知道我可以做这样的事情:
使用此代码,我正在创建将一个新项目添加到目标列表(名为destAttachList指定 destUrl,该destUrl表示此列表中放置项目的确切文件夹(我从上一个流程步骤中获得了此信息)。然后我只需设置目标列表中此项的 2 个字段使用我正在迁移的源列表项的值。
我的疑问是:
我可以将项目从源列表移动到目标列表(在目标 URL 指定的特定文件夹中)吗?
如果迁移中的这个项目包含附件,这些附件可以通过这个单一的移动步骤自动迁移吗?(如果可能的话)
sharepoint - 如何更新没有 ID 列的 SharePoint 列表项
我正在尝试更新 SharePoint 列表中的状态。做了一些谷歌搜索,发现大多数示例都使用 ID 列来定位列表项,但我的列表没有这样的列,只有 Windows 登录和状态列。我想知道 XML 会是什么样子?
这是我想出的,但它不起作用:
这是结果:
知道出了什么问题吗?
谢谢你。