pnpcore: Adding multiple ListItem problem
Category
- Bug
Describe the bug
I have a foreach cycle to define and upload multiple ListItem in a SharePoint List. The items are created inside some subfolders. (but I also tried in the root of the library) The first Item is correctly created, all the next items are not created and no error or exception is rised.
Steps to reproduce
IList list = await ctx.Web.Lists.GetByIdAsync(new Guid(config.Value.ListIdSessioniFormative));
foreach (var session in edition.sessions)
{
Dictionary<string, object> data = new Dictionary<string, object>()
{
{ "Title", edition.editionCode },
// various metadata
};
IListItem item = list.Items.Add(data, $"{folderCompany}/{folderYear}");
}
Expected behavior
A number of item equal to the foreach round should be created.
Environment details (development & target environment)
- SDK version: [1.2.0 ]
- OS: [Windows 10]
- SDK used in: [ASP.Net Web app]
- Framework: [.NET Core v3.1 ]
- Browser(s): [Chrome v90]
- Tooling: [Visual Studio 2019]
- Additional details:
Additional context
DELETE THIS LINE BEFORE SUBMITTING - Provide any other context about the problem.
Thanks for your contribution! Sharing is caring.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (15 by maintainers)
@Micael-stack : with tomorrow’s PnP PS build you should see an exception being thrown for this (as PnP PS was still using an old PnP Core library). Good that you’ve found the failing field…maybe create a PR for the PowerShell docs to clarify this?
@jansenbe If your static and internal dont match, it is because you got into two possibilities : the internal name was already used within the site, or, the length was too long. Static name is not unique and internal should always be prefered if we want perfect match…
@jansenbe i will look into it but from my side all my internal names and static names are normally the same. All my fields in my test were simple text and datetime.
@gopaldahal : check out this for handling lookup fields https://pnp.github.io/pnpcore/using-the-sdk/listitems-fields.html#lookup-fields. If you, when using the documented approach, cannot get saving the lookup field to work then please create a new issue with specific information on the lookup field.