{"id":969,"date":"2019-03-28T06:24:07","date_gmt":"2019-03-28T06:24:07","guid":{"rendered":"http:\/\/blog.softreeconsulting.com\/?p=969"},"modified":"2019-03-28T06:24:07","modified_gmt":"2019-03-28T06:24:07","slug":"how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/","title":{"rendered":"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer"},"content":{"rendered":"\n<p>In this blog, the method to add, update and delete SharePoint list view in SPFX application customizer is explained elaborately. We will see how we can use PnP in SPFX to perform all these list view operations.<\/p>\n\n\n\n<p>In the following code, we will go through step by step method to add our custom views with required properties, update an existing list view and finally how to delete a list view.<\/p>\n\n\n\n<p>Before you start using the code attached you have to first install PnP using the command \u201cnpm install sp-pnp-js \u2013save\u201d.<\/p>\n\n\n\n<p><strong>The code block for this is mentioned below.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { override } from '@microsoft\/decorators';\nimport { Log } from '@microsoft\/sp-core-library';\nimport {\nBaseApplicationCustomizer\n} from '@microsoft\/sp-application-base';\nimport { Dialog } from '@microsoft\/sp-dialog';\nimport pnp from 'sp-pnp-js';\n\nimport * as strings from 'HelloWorldApplicationCustomizerStrings';\n\nconst LOG_SOURCE: string = 'HelloWorldApplicationCustomizer';\n\n\/**\n* If your command set uses the ClientSideComponentProperties JSON input,\n* it will be deserialized into the BaseExtension.properties object.\n* You can define an interface to describe it.\n*\/\nexport interface IHelloWorldApplicationCustomizerProperties {\n\/\/ This is an example; replace with your own property\ntestMessage: string;\n}\n\n\/** A Custom Action which can be run during execution of a Client Side Application *\/\nexport default class HelloWorldApplicationCustomizer\nextends BaseApplicationCustomizer&amp;lt;IHelloWorldApplicationCustomizerProperties&amp;gt; {\n\n@override\npublic onInit(): Promise&amp;lt;void&amp;gt; {\npnp.setup({\nspfxContext: this.context\n});\n\n\/\/The following method is to add a new view in list with specific properties\n\/\/and also you can add those fields you want to include in this new list view.\npnp.sp.web.lists.getByTitle(&amp;quot;MyList&amp;quot;).views.add(&amp;quot;MyCustomView&amp;quot;, false, {\n\nRowLimit: 10,\nDefaultView: true,\nViewQuery: &amp;quot;&amp;lt;OrderBy&amp;gt;&amp;lt;FieldRef Name='Modified' Ascending='False' \/&amp;gt;&amp;lt;\/OrderBy&amp;gt;&amp;quot;,\n}).then((v: ViewAddResult) =&amp;gt; {\n\nv.view.fields.removeAll().then(_ =&amp;gt; {\n\nPromise.all([\nv.view.fields.add(&amp;quot;Title&amp;quot;),\nv.view.fields.add(&amp;quot;Id&amp;quot;),\nv.view.fields.add(&amp;quot;Modified&amp;quot;),\n]).then(_ =&amp;gt;{\n\nconsole.log(&amp;quot;Custom listview created.&amp;quot;);\n});\n});\n});\n\n\/\/This following method will update the properties in your list view\npnp.sp.web.lists.getByTitle(&amp;quot;MyList&amp;quot;).views.getByTitle(&amp;quot;MyCustomView&amp;quot;).update({\nRowLimit: 20,\n}).then((v: ViewUpdateResult) =&amp;gt; {\n\nconsole.log(&amp;quot;Custom listview updated successfully.&amp;quot;);\n});\n\n\/\/The following method will delete the list view\npnp.sp.web.lists.getByTitle(&amp;quot;MyList&amp;quot;).views.getByTitle(&amp;quot;MyCustomView&amp;quot;).delete().then(_ =&amp;gt; {\n\nconsole.log(&amp;quot;Custom listview deleted.&amp;quot;);\n});\n\nreturn Promise.resolve();\n}\n}<\/code><\/pre>\n\n\n\n<p>After PnP is installed successfully use the attached code in your SPFX solution to go through all SPList view operations&#8230;<\/p>\n\n\n\n<p><strong>This solution is brought to you by our SharePoint professionals.<\/strong><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\"Softree Consulting (opens in a new tab)\" href=\"http:\/\/www.softreeconsulting.com\/\" target=\"_blank\">Softree Technology<\/a>\u00a0employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.<\/p>\n\n\n\n<p>Be it\u00a0SPFx or SharePoint\u00a0add-in developments,\u00a0SharePoint 2019 developments, web part developments, migrating from SharePoint 2010\/2013 to SharePoint 2013\/2016\/Office 365, Office 365,\u00a0SharePoint hosted apps development\u00a0or something else in SharePoint, we strive to deliver the best<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, the method to add, update and delete SharePoint list view in SPFX application customizer is explained elaborately. We will see how we can use PnP in SPFX to perform all these list view operations. In the following code, we will go through step by step method to add our custom views with required properties, update an existing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[229,230,231],"class_list":["post-969","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-how-to-add","tag-sharepoint-list-view-operations-in-spfx-using-pnp","tag-update-and-delete-list-view-in-spfx-using-pnp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"In this blog, the method to add, update and delete SharePoint list view in SPFX application customizer is explained elaborately. We will see how we can use PnP in SPFX to perform all these list view operations. In the following code, we will go through step by step method to add our custom views with required properties, update an existing [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-28T06:24:07+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/","og_locale":"en_US","og_type":"article","og_title":"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer - Softree Technology","og_description":"In this blog, the method to add, update and delete SharePoint list view in SPFX application customizer is explained elaborately. We will see how we can use PnP in SPFX to perform all these list view operations. In the following code, we will go through step by step method to add our custom views with required properties, update an existing [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/","og_site_name":"Softree Technology","article_published_time":"2019-03-28T06:24:07+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer","datePublished":"2019-03-28T06:24:07+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/"},"wordCount":216,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"keywords":["how to add","SharePoint list view operations in spfx using pnp","update and delete list view in spfx using pnp"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/","name":"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"datePublished":"2019-03-28T06:24:07+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-add-update-and-delete-sharepoint-list-view-using-pnp-in-spfx-application-customizer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Add, Update and Delete SharePoint List View Using Pnp In SPFX Application-Customizer"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=969"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/969\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}