{"id":6932,"date":"2021-09-07T11:32:15","date_gmt":"2021-09-07T11:32:15","guid":{"rendered":"https:\/\/softreetechnology.com\/?p=6932"},"modified":"2021-09-07T11:32:18","modified_gmt":"2021-09-07T11:32:18","slug":"copy-modern-page-within-the-folder-using-jsom","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/","title":{"rendered":"Copy Modern Page Within The Folder Using JSOM"},"content":{"rendered":"\n<p>In this blog, we are going to discuss how to copy a modern page within the same folder of a site collection. You can do it manually or programmatically. Follow the below steps to copy a client-side page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Copy a page manually<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>Go to your site\u2019s Site Pages. Select a page.<\/li><li>Click on \u201c<strong>Three dots<\/strong>\u201d to present the right side of a page as shown below. Then click on \u201c<strong>Copy to<\/strong>\u201d.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>3. A pop-up will open, select the Folder, then click on \u201c<strong>Copy here<\/strong>\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis2.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How to Copy a Modern page programmatically using JavaScript<\/h2>\n\n\n\n<p>Follow the below JavaScript code to copy a modern page in the same folder of a site collection.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var fileLibName = \u201chome.aspx\u201d;\nvar newFileName = \u201cTest.aspx \";\nvar fileContentUrl = &lt; enter your siteUrl &gt; +\"\/_api\/web\/GetFileByServerRelativeUrl('\" + fileName + \"')\/$value\";\nvar restUrl = &lt; enter your siteUrl &gt; +\"\/_api\/web\/GetFolderByServerRelativeUrl('\" + folderName + \"')\/Files\/Add(url='\" + newFileName + \"',overwrite=true)\";\n$(function() {\n    $.ajax({\n        url: &lt; enter your siteUrl &gt; +\"\/_api\/contextinfo\",\n        type: 'POST',\n        processData: false,\n        headers: {\n            \"Accept\": \"application\/json; odata=verbose\",\n            \"X-RequestDigest\": $('#__REQUESTDIGEST').val(),\n        },\n        success: successHandler,\n        error: errorHandler\n    })\n})\n\nfunction successHandler(data, textStatus, jqXHR) {\n    var digest = data.d.GetContextWebInformation.FormDigestValue;\n    var xhr = new XMLHttpRequest();\n    xhr.open('GET', fileContentUrl, true);\n    xhr.setRequestHeader('binaryStringResponseBody', true);\n    xhr.responseType = 'arraybuffer';\n    xhr.onload = function(e) {\n        if (this.status == 200) {\n            var arrayBuffer = this.response;\n            $.ajax({\n                url: restUrl,\n                method: 'POST',\n                data: arrayBuffer,\n                processData: false,\n                headers: {\n                    'binaryStringRequestBody': 'true',\n                    'Accept': 'application\/json;odata=verbose;charset=utf-8',\n                    'X-RequestDigest': digest\n                }\n            }).done(function(postData) {\n                Console.log(\u201cCopied successfully\u201d);\n            }).fail(function(jqXHR, errorText) {\n                Console.log(\u201cError\u201d);\n            });\n        }\n    }\n    xhr.send();\n}\n\nfunction errorHandler(xhr, ajaxOptions, thrownError) {\n    var msg = \"FAILED: \" + xhr.responseText;\n    console.log(msg);\n}<\/code><\/pre>\n\n\n\n<p>JavaScript<\/p>\n\n\n\n<p><strong>The original page<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis3.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>The copied Page<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis4.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>We can conclude that this copy feature will help a user copying a page with all the contents present inside the page. Hence, we have done it programmatically to make this easier and more effective.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we are going to discuss how to copy a modern page within the same folder of a site collection. You can do it manually or programmatically. Follow the below steps to copy a client-side page. How to Copy a page manually Go to your site\u2019s Site Pages. Select a page. Click on \u201cThree dots\u201d to present the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-6932","post","type-post","status-publish","format-standard","hentry","category-sharepoint"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Copy Modern Page Within The Folder Using JSOM - 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\/copy-modern-page-within-the-folder-using-jsom\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Copy Modern Page Within The Folder Using JSOM - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"In this blog, we are going to discuss how to copy a modern page within the same folder of a site collection. You can do it manually or programmatically. Follow the below steps to copy a client-side page. How to Copy a page manually Go to your site\u2019s Site Pages. Select a page. Click on \u201cThree dots\u201d to present the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-07T11:32:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-07T11:32:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png\" \/>\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":"Copy Modern Page Within The Folder Using JSOM - 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\/copy-modern-page-within-the-folder-using-jsom\/","og_locale":"en_US","og_type":"article","og_title":"Copy Modern Page Within The Folder Using JSOM - Softree Technology","og_description":"In this blog, we are going to discuss how to copy a modern page within the same folder of a site collection. You can do it manually or programmatically. Follow the below steps to copy a client-side page. How to Copy a page manually Go to your site\u2019s Site Pages. Select a page. Click on \u201cThree dots\u201d to present the [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/","og_site_name":"Softree Technology","article_published_time":"2021-09-07T11:32:15+00:00","article_modified_time":"2021-09-07T11:32:18+00:00","og_image":[{"url":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png","type":"","width":"","height":""}],"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\/copy-modern-page-within-the-folder-using-jsom\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Copy Modern Page Within The Folder Using JSOM","datePublished":"2021-09-07T11:32:15+00:00","dateModified":"2021-09-07T11:32:18+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/"},"wordCount":164,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#primaryimage"},"thumbnailUrl":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png","articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/","name":"Copy Modern Page Within The Folder Using JSOM - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#primaryimage"},"thumbnailUrl":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png","datePublished":"2021-09-07T11:32:15+00:00","dateModified":"2021-09-07T11:32:18+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#primaryimage","url":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png","contentUrl":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/09062021101517AM\/bis1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/copy-modern-page-within-the-folder-using-jsom\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Copy Modern Page Within The Folder Using JSOM"}]},{"@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\/6932","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=6932"}],"version-history":[{"count":1,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6932\/revisions"}],"predecessor-version":[{"id":6933,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6932\/revisions\/6933"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=6932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=6932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=6932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}