"Collaborative Drive" assistance within Google Apps Script

Currently, I am developing a JavaScript tool within Google Apps Script to analyze various document properties such as the validity of links and correct permissions settings. To achieve this, I have been utilizing the API outlined in https://developers.google.com/apps-script/reference/drive/drive-app for tasks like searching for files by ID, validating permissions, and managing files on Google Drive. However, I encountered challenges when dealing with "Shared Drives" while interacting with this API.

Some issues include:

  • The root folder of a Shared Drive returns "Drive" instead of its actual name when using
    <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="34594d53465b414474505b59555d5a1a575b59">[email protected]</a>
    ,
  • Even though
    <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d00140a1f02181d2d0902000c04e00c040004e00corknotionsofeoyrpeurekaediaonceeme.com" target="_blank" rel="noopener noreferrer noopener nofollow">[email protected]</a>
    has "Manager" access to the Shared Drive, some methods like
    folder.getAccess('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="67eeebfbefe9fdedabfcfbd3dbcbda8bcddcdcdeec3cfcd">[email protected]</a>')
    return NONE and folder.getViewers() is empty,
  • There are situations where folders within Shared Drives do not consistently appear in the DriveApp.getFolders() iterator.

The second point mentioned above is currently impeding my progress. Can anyone provide insights into whether there is an alternative API that I should be leveraging or if this issue is a bug that needs to be reported? Additionally, I am seeking documentation regarding the limitations associated with using the Drive API functionalities within a Shared Drive context.

Answer №1

Opt for the Advanced Drive Service over DriveApp

  • It's true that DriveApp does not support shared drives and has a limited scope
  • However, by enabling the Advanced Drive Service, you gain access to all functionalities of the Drive API v2, including support for shared drives in Apps Script

Example:

function myFunction() {
  var sharedDriveName = Drive.Drives.get("XXXXXXXXXXXXXXXXXXX").name;
  //Remember to specify that the folder is on a shared drive with {"supportsAllDrives": true}
  var folderOnDriveName = Drive.Files.get("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",{"supportsAllDrives": true}).title;
  var folderPermissions = Drive.Permissions.list("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",{"supportsAllDrives": true});
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Maintain a fixed element and enable the rest of the elements to scroll as the mobile browser address bar collapses while scrolling upwards

Currently facing a challenge where I want the background image to remain static while the address bar and content underneath scroll up. The image occupies 90% of the view height, and although I've prevented it from resizing and jumping when the addres ...

The functionality of using multiple inputs with Google Places API is not functioning as expected

Having trouble with the Google Place API. I am unable to set up 2 input fields with autocomplete. The first input is populated from a payload received from the backend, while the second input is within a Bootstrap modal. I have tried various solutions fou ...

What options do I have for personalizing this Google Bar Graph?

I am currently working on creating a Google bar chart. You can view my progress here: http://jsfiddle.net/nGvdB/ Although I have carefully reviewed the Google Bar Chart documentation available here, I am struggling to customize the chart to my needs. Spec ...

The Electron forge project from publisher-github is failing to detect the environment variable GITHUB-TOKEN

I've set up my .env file with the correct token, but I encountered an error when trying to publish my package on GitHub. An unhandled rejection has occurred inside Forge: Error: Please set GITHUB_TOKEN in your environment to access these features at n ...

Tips for implementing a repeater item to function beyond the ng-repeat directive

Recently, I decided to play around with AngularJS and now I seem to be facing a small issue with ng-class. Specifically, I'm attempting to change the color of an awesome font icon. <div ng-controller="MyCtrl"> <i ng-class="{'test': ...

Different ways to call an ES6 class that is bundled in the <script> tag

Currently, I am utilizing Webpack to transpile my ES6 classes. Within the bundle, there is a Service class that can be imported by other bundled scripts. class Service { constructor() { // } someMethod(data) { // } } expo ...

An issue with jQuery's :not selector and hash symbol syntax

I encountered a syntax error that is quite charming. It appears when attempting to select all anchor tags without an href attribute containing a placeholder URL, such as href="#". Here are the attempts I have made: $("a:not(href='#')"); // cha ...

Adjusting the input in a Textfield within React using Material UI

const [formData, setFormData] = useState({}); useEffect(() => { fetch("/formdata") .then((res) => res.json()) .then((data) => setFormData(data)); }, []); console.log("Form Data", formData); //Sorting by order let attr; ...

Choosing elements in HTML using jQuery from an Ajax GET response

As a programming student, I am currently working on developing a basic website using HTML, JavaScript, and jQuery for the front-end, while utilizing node.js and Express frameworks for the back-end. In my project, I have used Ajax to retrieve data and then ...

Transmit JSON information using jQuery

Can you explain why the code below is sending data as City=Moscow&Age=25 instead of in JSON format? var arr = {City:'Moscow', Age:25}; $.ajax( { url: "Ajax.ashx", type: "POST", data: arr, dataType: 'js ...

Prevent clicking on a div using Jquery

Imagine I have a simple click event set up for an HTML div element. When the div is clicked, it should trigger a fadeToggle effect. Inside that div, there is another nested div with its own click event. Upon clicking this inner div, it is supposed to do s ...

Automatically navigate to a specific element as the user scrolls down the page

I am attempting to achieve a similar effect as seen on the App Builder Website. When the user reaches the header with the background image/video and scrolls down, the website smoothly transitions to the next div/section. If the user scrolls back up and ret ...

A guide on incorporating LINQ in the Microsoft ClearScript V8 platform

Currently, I am making use of microsoft.clearscript.v8 in ASP.Net Core MVC. The following code snippet can be found in my Home controller: public async Task<IActionResult> Index() { using (var engine1 = new V8ScriptEngine()) { engine1 ...

JQuery AJAX not retrieving data after $.post request

I am currently facing a challenge with a specific JQuery $.post request to a PHP-based processor. To troubleshoot, I set up a test page containing the following code: It's important to note that this is hosted on a subdomain, but there are no cross-d ...

C# - Implementing JavaScript Object manipulation in .NET Core

As I was browsing, I noticed many similar questions from years ago. Let's kick off this discussion with a simple JavaScript example showcasing how easy it is to modify, read, and write properties in objects using this language. Take a look at the cod ...

Designing a personalized look for a property with Styled-System

Styled-System offers various props related to css grid: I have a suggestion for a new prop, gridWrap. My idea is to allow users to adjust the auto-fit value using the gridWrap prop. Here's the base CSS code: grid-template-columns: repeat(auto-fit, mi ...

Is being unfazed by work a common occurrence?

After completing a complex cycle that processes data from the database and writes it to an array, I encounter a situation where the array processing function is triggered before the array is fully populated. This forces me to use setTimeout() for proper ti ...

I attempted to implement an AJAX partial refresh for my HTML, but unfortunately, it did not have the

I've been attempting to implement Ajax to locally load the page, but unfortunately, the code below isn't functioning as expected. My intention is to transmit the 'MSG' information from 'views' to Ajax and refresh the page loca ...

Connect user input to a predefined value within an object

I am currently working on developing a timesheet application that allows users to input the number of hours they work daily. The user data is stored in an object, and I aim to display each user's hours (duration) in an input field within a table. An i ...

Retrieving the values of multiple selected options from various select fields simultaneously

Picture having a dynamic number of select fields (the value of this variable is not fixed). I am looking to extract the values of the selected option from each select field using jQuery (or vanilla JavaScript). This is my approach: var cars = $(".sele ...