{"id":270,"date":"2024-02-27T17:45:27","date_gmt":"2024-02-27T17:45:27","guid":{"rendered":"https:\/\/technology.corporatesstore.com\/?page_id=270"},"modified":"2024-03-02T05:31:20","modified_gmt":"2024-03-02T05:31:20","slug":"apps-script","status":"publish","type":"page","link":"https:\/\/technology.corporatesstore.com\/index.php\/webhosting-fundamentals\/apps-script\/","title":{"rendered":"Apps Script"},"content":{"rendered":"\n<p><strong>List Published URLs for Tabs<\/strong><\/p>\n\n\n\n<p>Consider the below script as explained in <a href=\"https:\/\/stackoverflow.com\/questions\/74125629\/list-of-all-tabs-publish-to-web-links-on-a-large-googlesheet-document-200-ta\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/stackoverflow.com\/questions\/74125629\/list-of-all-tabs-publish-to-web-links-on-a-large-googlesheet-document-200-ta<\/a><\/p>\n\n\n\n<p><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">function ListPublishedURLs() {<\/mark><\/p>\n\n\n\n<p><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">\u00a0 const baseUrl = &#8220;&lt;Published URL of Entire Document>&#8221;; \/\/ Please modify this for your URL.<\/mark><\/p>\n\n\n\n<p><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">\u00a0 return SpreadsheetApp.getActiveSpreadsheet().getSheets().map(s => `${baseUrl}?single=true&amp;gid=${s.getSheetId()}`);<\/mark><\/p>\n\n\n\n<p><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">}<\/mark><\/p>\n\n\n\n<p>Copy and paste the above script to the script editor of Google Spreadsheet as follows:<\/p>\n\n\n\n<p>Sheet &#8211;> Extenstions &#8211;> Apps Script &#8211;> Files &#8211;> <a href=\"http:\/\/code.gs\/\">code.gs<\/a><\/p>\n\n\n\n<p>Replace baseURL with the published URL of entire google sheet as follows:<\/p>\n\n\n\n<p>File &#8211;> Share &#8211;> Publish to Web &#8211;> Link &#8211;> Entire Document &#8211;> Copy the Published URL.<\/p>\n\n\n\n<p>Add sheets to services as follows:<\/p>\n\n\n\n<p>Services &#8211;> Google Sheets API &#8211;> Add.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"756\" height=\"793\" src=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image.png\" alt=\"\" class=\"wp-image-279\" srcset=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image.png 756w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-600x629.png 600w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-286x300.png 286w\" sizes=\"auto, (max-width: 756px) 100vw, 756px\" \/><\/figure>\n\n\n\n<p>Give a name to the Project, and Save:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1858\" height=\"436\" src=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3.png\" alt=\"\" class=\"wp-image-282\" srcset=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3.png 1858w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3-600x141.png 600w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3-300x70.png 300w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3-1024x240.png 1024w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3-768x180.png 768w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-3-1536x360.png 1536w\" sizes=\"auto, (max-width: 1858px) 100vw, 1858px\" \/><\/figure>\n\n\n\n<p>Run the Project, and Review Permissions as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"217\" src=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-4.png\" alt=\"\" class=\"wp-image-283\" srcset=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-4.png 614w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-4-600x212.png 600w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-4-300x106.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/figure>\n\n\n\n<p>Choose and Account:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"687\" height=\"493\" src=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-5.png\" alt=\"\" class=\"wp-image-284\" srcset=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-5.png 687w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-5-600x431.png 600w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-5-300x215.png 300w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/figure>\n\n\n\n<p>Allow access to the project as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"686\" height=\"880\" src=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-7.png\" alt=\"\" class=\"wp-image-286\" srcset=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-7.png 686w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-7-600x770.png 600w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-7-234x300.png 234w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/figure>\n\n\n\n<p>Verify the execution log as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"162\" src=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-8.png\" alt=\"\" class=\"wp-image-287\" srcset=\"https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-8.png 500w, https:\/\/technology.corporatesstore.com\/wp-content\/uploads\/2024\/03\/image-8-300x97.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<p>When you use this script, please put a custom function of =SAMPLE() at the address bar of Google Sheet. By this, the URLs are returned.<\/p>\n\n\n\n<p><strong>List Tabs with URL<\/strong><\/p>\n\n\n\n<p>Consider the following script as explained in <a href=\"https:\/\/support.google.com\/docs\/thread\/25861942\/create-a-list-of-the-tabs-in-a-google-workbook-updates-automatically-and-links-to-tabs?hl=en#:~:text=Check%20if%20a%20new%20menu,the%20first%20sheet%2Ftab'.\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/support.google.com\/docs\/thread\/25861942\/create-a-list-of-the-tabs-in-a-google-workbook-updates-automatically-and-links-to-tabs?hl=en#:~:text=Check%20if%20a%20new%20menu,the%20first%20sheet%2Ftab&#8217;.<\/a><\/p>\n\n\n\n<p><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">function onOpen() { SpreadsheetApp.getUi().createMenu(&#8216;Tabs&#8217;) .addItem(&#8216;List tabs&#8217;, &#8216;sheetNames&#8217;) .addToUi() } function sheetNames() { var ss, list, tar; ss = SpreadsheetApp.getActive() list = ss.getSheets().slice(1).map(function (s, ind) { return [&#8216;=HYPERLINK(&#8220;#gid=&#8217; + s.getSheetId() + &#8216;&#8221;, &#8220;&#8216; + s.getName() + &#8216;&#8221;)&#8217;]; }) tar = ss.getSheets()[0]; \/\/List will be written to FIRST sheet in the workbook. tar.getRange(2, 4, tar.getLastRow(), 1).clearContent(); tar.getRange(2, 4, list.length, 1).setValues(list) } function onChange(e) { if ([&#8216;REMOVE_GRID&#8217;, &#8216;INSERT_GRID&#8217;, &#8216;OTHER&#8217;].indexOf(e.changeType) > -1) { sheetNames() } } \/*Only run this function ONCE. You can check if the trigger has been set correctly by clicking &#8216;Edit&#8217; > &#8216;Triggers for current project&#8217;*\/ function createOnChangeTrigger() { ScriptApp.newTrigger(&#8220;onChange&#8221;) .forSpreadsheet(SpreadsheetApp.getActive()) .onChange() .create(); }<\/mark><\/p>\n\n\n\n<p>Once the above code is used, Tab will appear in the desired Google Sheets. Click the Tab, it will display the Tab URLs in Column D of Google Sheet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>List Published URLs for Tabs Consider the below script as explained in https:\/\/stackoverflow.com\/questions\/74125629\/list-of-all-tabs-publish-to-web-links-on-a-large-googlesheet-document-200-ta function ListPublishedURLs() { \u00a0 const baseUrl = &#8220;&lt;Published URL of Entire Document>&#8221;; \/\/ Please modify this for your URL. \u00a0 return SpreadsheetApp.getActiveSpreadsheet().getSheets().map(s => `${baseUrl}?single=true&amp;gid=${s.getSheetId()}`); } Copy and paste the above script to the script editor of Google Spreadsheet as follows: Sheet &#8211;> [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":240,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-270","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/pages\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":3,"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/pages\/270\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/pages\/270\/revisions\/288"}],"up":[{"embeddable":true,"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/pages\/240"}],"wp:attachment":[{"href":"https:\/\/technology.corporatesstore.com\/index.php\/wp-json\/wp\/v2\/media?parent=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}