{"action":"created","issue":{"url":"https://api.github.com/repos/SharePoint/PnP-JS-Core/issues/569","repository_url":"https://api.github.com/repos/SharePoint/PnP-JS-Core","labels_url":"https://api.github.com/repos/SharePoint/PnP-JS-Core/issues/569/labels{/name}","comments_url":"https://api.github.com/repos/SharePoint/PnP-JS-Core/issues/569/comments","events_url":"https://api.github.com/repos/SharePoint/PnP-JS-Core/issues/569/events","html_url":"https://github.com/SharePoint/PnP-JS-Core/issues/569","id":253034369,"number":569,"title":"Batching multi item updates creating a call for each item","user":{"login":"simkessy","id":5871660,"avatar_url":"https://avatars1.githubusercontent.com/u/5871660?v=4","gravatar_id":"","url":"https://api.github.com/users/simkessy","html_url":"https://github.com/simkessy","followers_url":"https://api.github.com/users/simkessy/followers","following_url":"https://api.github.com/users/simkessy/following{/other_user}","gists_url":"https://api.github.com/users/simkessy/gists{/gist_id}","starred_url":"https://api.github.com/users/simkessy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simkessy/subscriptions","organizations_url":"https://api.github.com/users/simkessy/orgs","repos_url":"https://api.github.com/users/simkessy/repos","events_url":"https://api.github.com/users/simkessy/events{/privacy}","received_events_url":"https://api.github.com/users/simkessy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-08-25T22:42:49Z","updated_at":"2017-08-28T13:28:03Z","closed_at":null,"body":"I'm trying to do a batch update of list items and reduce the get list item calls: \r\n\r\n![image](https://user-images.githubusercontent.com/5871660/29735196-1723c6b2-89c5-11e7-81eb-41dff7e420c6.png)\r\n\r\nI thought batch or caching would help here but I think I'm missing something. \r\n\r\n```\r\nimport pnp from \"pnp\";\r\n\r\nvar list = pnp.sp.web.lists.getByTitle(\"Projects\");\r\nlist.items.get().then(function(items) {\r\n\tvar batch = pnp.sp.createBatch()\r\n\t// see if we got something\r\n\tif (items.length > 0) {\r\n\t\titems.map(function(item, index) {\r\n\t\t\tlist.items.usingCaching().getById(items[index].Id).inBatch(batch).update({\r\n\t\t\t\t\"BA_GroupRenameAgain\": \"Unassigned\",\r\n\t\t\t}).catch(console.log)\r\n\t\t})\r\n\t}\r\n\tbatch.execute().then(() => console.log(\"All done!\"));\r\n});\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/SharePoint/PnP-JS-Core/issues/comments/325353121","html_url":"https://github.com/SharePoint/PnP-JS-Core/issues/569#issuecomment-325353121","issue_url":"https://api.github.com/repos/SharePoint/PnP-JS-Core/issues/569","id":325353121,"user":{"login":"patrick-rodgers","id":13154702,"avatar_url":"https://avatars3.githubusercontent.com/u/13154702?v=4","gravatar_id":"","url":"https://api.github.com/users/patrick-rodgers","html_url":"https://github.com/patrick-rodgers","followers_url":"https://api.github.com/users/patrick-rodgers/followers","following_url":"https://api.github.com/users/patrick-rodgers/following{/other_user}","gists_url":"https://api.github.com/users/patrick-rodgers/gists{/gist_id}","starred_url":"https://api.github.com/users/patrick-rodgers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrick-rodgers/subscriptions","organizations_url":"https://api.github.com/users/patrick-rodgers/orgs","repos_url":"https://api.github.com/users/patrick-rodgers/repos","events_url":"https://api.github.com/users/patrick-rodgers/events{/privacy}","received_events_url":"https://api.github.com/users/patrick-rodgers/received_events","type":"User","site_admin":false},"created_at":"2017-08-28T13:28:03Z","updated_at":"2017-08-28T13:28:03Z","body":"Please have a look at this [wiki entry](https://github.com/SharePoint/PnP-JS-Core/wiki/Working-With:-Items#add-multiple-items). We have to retrieve the ListItemEntityTypeFullName from the list for the update as SP requires it is used. SO we do that on a per request basis as the requests don't (and shouldn't) know about or rely on other requests. This is suboptimal when adding lots of items, hence the pattern linked in the wiki article. That should get you sorted. Thanks!"}}
{"actor":{"display_login":"patrick-rodgers"}}