From 4db90e87432a7fd2284b370571813f168da42e98 Mon Sep 17 00:00:00 2001 From: Chanel Greco Date: Thu, 1 Dec 2022 13:07:46 +0100 Subject: [PATCH 1/3] Sample for the AppSheet and Apps Script video tutorial --- solutions/automations/folder-creation/Code.js | 33 +++++++++++++++++++ .../automations/folder-creation/README.md | 11 +++++++ .../folder-creation/appscript.json | 14 ++++++++ 3 files changed, 58 insertions(+) create mode 100644 solutions/automations/folder-creation/Code.js create mode 100644 solutions/automations/folder-creation/README.md create mode 100644 solutions/automations/folder-creation/appscript.json diff --git a/solutions/automations/folder-creation/Code.js b/solutions/automations/folder-creation/Code.js new file mode 100644 index 000000000..e9db07dce --- /dev/null +++ b/solutions/automations/folder-creation/Code.js @@ -0,0 +1,33 @@ +// To learn how to use this script, refer to the video: https://youtu.be/Utl57R7I2Cs + +/* +Copyright 2022 Google LLC +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + https://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +/* +This function will create a new folder in the defined Shard Drive. +You define the Shared Drive by adding its ID on line number 26. +The parameter 'project' is passed in from the AppSheet app. +Please watch this video tutorial to see how to use this script: https://youtu.be/Utl57R7I2Cs +*/ + +function createNewFolder(project) { + const newFolderId = Drive.Files.insert({ + parents: [{id: [ADD YOUR SHARED DRIVE FOLDER ID HERE]}], + title: project, + mimeType: 'application/vnd.google-apps.folder' + }, null, {supportsAllDrives: true}).id; + + return `https://drive.google.com/drive/folders/${newFolderId}?usp=share_link`; + } + \ No newline at end of file diff --git a/solutions/automations/folder-creation/README.md b/solutions/automations/folder-creation/README.md new file mode 100644 index 000000000..357c71aaa --- /dev/null +++ b/solutions/automations/folder-creation/README.md @@ -0,0 +1,11 @@ +# Folder creation + +This code sample is part of a video tutorial on how to combine AppSheet and Apps Script. + +You can watch the video tutorial to find out how to use the sample. + +

+ +

+ +See the [Google Apps Script Documentation] (https://developers.google.com/apps-script/advanced/drive) for additional information about the advanced Google Drive services. \ No newline at end of file diff --git a/solutions/automations/folder-creation/appscript.json b/solutions/automations/folder-creation/appscript.json new file mode 100644 index 000000000..de9678f42 --- /dev/null +++ b/solutions/automations/folder-creation/appscript.json @@ -0,0 +1,14 @@ +{ + "timeZone": "Europe/Madrid", + "dependencies": { + "enabledAdvancedServices": [ + { + "userSymbol": "Drive", + "version": "v2", + "serviceId": "drive" + } + ] + }, + "exceptionLogging": "STACKDRIVER", + "runtimeVersion": "V8" + } \ No newline at end of file From cccfde21e4e4620adc16b5d853a783548fd93022 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Fri, 9 Dec 2022 10:24:54 -0700 Subject: [PATCH 2/3] fix: make requested changes --- solutions/automations/folder-creation/Code.js | 62 ++++++++++--------- .../automations/folder-creation/README.md | 6 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/solutions/automations/folder-creation/Code.js b/solutions/automations/folder-creation/Code.js index e9db07dce..51df363e1 100644 --- a/solutions/automations/folder-creation/Code.js +++ b/solutions/automations/folder-creation/Code.js @@ -1,33 +1,37 @@ -// To learn how to use this script, refer to the video: https://youtu.be/Utl57R7I2Cs - -/* -Copyright 2022 Google LLC -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - +/** + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -/* -This function will create a new folder in the defined Shard Drive. -You define the Shared Drive by adding its ID on line number 26. -The parameter 'project' is passed in from the AppSheet app. -Please watch this video tutorial to see how to use this script: https://youtu.be/Utl57R7I2Cs -*/ +// To learn how to use this script, refer to the video: https://youtu.be/Utl57R7I2Cs +/** + * This function will create a new folder in the defined Shard Drive. You define + * the Shared Drive by adding its ID on line number 28. The parameter `project` + * is passed in from the AppSheet app. Please watch this video tutorial to see + * how to use this script: https://youtu.be/Utl57R7I2Cs. + */ function createNewFolder(project) { - const newFolderId = Drive.Files.insert({ - parents: [{id: [ADD YOUR SHARED DRIVE FOLDER ID HERE]}], + const folder = Drive.Files.insert( + { + parents: [{ id: 'ADD YOUR SHARED DRIVE FOLDER ID HERE' }], title: project, - mimeType: 'application/vnd.google-apps.folder' - }, null, {supportsAllDrives: true}).id; - - return `https://drive.google.com/drive/folders/${newFolderId}?usp=share_link`; - } - \ No newline at end of file + mimeType: "application/vnd.google-apps.folder", + }, + null, + { supportsAllDrives: true } + ); + + return folder.alternateLink; +} diff --git a/solutions/automations/folder-creation/README.md b/solutions/automations/folder-creation/README.md index 357c71aaa..c13835384 100644 --- a/solutions/automations/folder-creation/README.md +++ b/solutions/automations/folder-creation/README.md @@ -2,10 +2,6 @@ This code sample is part of a video tutorial on how to combine AppSheet and Apps Script. -You can watch the video tutorial to find out how to use the sample. - -

- -

+You can watch the video tutorial to find out how to use the sample at https://youtu.be/Utl57R7I2Cs. See the [Google Apps Script Documentation] (https://developers.google.com/apps-script/advanced/drive) for additional information about the advanced Google Drive services. \ No newline at end of file From 74fcaa34a0c588f73c43b32f65f901e08f67b43a Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Fri, 9 Dec 2022 10:25:51 -0700 Subject: [PATCH 3/3] fix: broken markdown link --- solutions/automations/folder-creation/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/automations/folder-creation/README.md b/solutions/automations/folder-creation/README.md index c13835384..aa76b2b76 100644 --- a/solutions/automations/folder-creation/README.md +++ b/solutions/automations/folder-creation/README.md @@ -4,4 +4,4 @@ This code sample is part of a video tutorial on how to combine AppSheet and Apps You can watch the video tutorial to find out how to use the sample at https://youtu.be/Utl57R7I2Cs. -See the [Google Apps Script Documentation] (https://developers.google.com/apps-script/advanced/drive) for additional information about the advanced Google Drive services. \ No newline at end of file +See the [Google Apps Script Documentation](https://developers.google.com/apps-script/advanced/drive) for additional information about the advanced Google Drive services. \ No newline at end of file