Tips for indicating request parameters in Drive.Comments.list

I have successfully retrieved the default 20 comments using the code below by specifying a single fileId parameter. However, I am interested in pulling back one hundred comments or paginating to the next set of 20 out of curiosity.

In my getComments function below, when I pass options as a parameter to Drive.Comments.list, it results in an error. But when I directly specify the fileId, it returns 20 comments.

I believe this should be an easy fix - I am still learning. Any suggestions would be greatly appreciated! Thank you!

function main() {
  var fileId = getFileId();
  var fileComments = getComments(fileId);
  //logObj(fileComments);
  //Logger.log(fileComments);//.items.length); // this always says 20 
  //logObj(fileComments);
  logObj(fileComments.items);
}

function getFileId() {
  return DocumentApp.getActiveDocument().getId(); 
}
function getComments(fileId) {
  var options = {
    'fileId': fileId,
    'pageSize': 99  
  };

  var commnts = Drive.Comments.list(fileId);

  return commnts;
  //Logger.log(cmnts.items.length);
}
function logObj(obj){
  for (key in obj) {
    var tmp =  obj[key];
    Logger.log(key + " = " + tmp );
  }
}

function findComments(criteria){

}

Answer №1

When using the Drive.Comments.list() function, remember it requires two parameters: (fileId, {options}). One important option to note is maxResults, which can be set between 0 and 100. To handle large data sets, utilize the result commnts.nextPageToken with options.pageToken.

function retrieveComments(fileId) {
  var options = {
    'maxResults': 99  
  };

  var commnts = Drive.Comments.list(fileId, options);

  return commnts;
  //Logger.log(cmnts.items.length);
}

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

Checking the dimensions and information of a JSON collection - a step-by-step guide

Recently, I've encountered a JSON String that was returned with an array inside in my Java SpringBoot application. {... "downlineLevels": ["01","02","03","04","05","06","07"] } Unfortunately, only the following JUnit tests have passed. 1) .andExpec ...

Best practices for working with HTML elements using JavaScript

What is the best approach for manipulating HTML controls? One way is to create HTML elements dynamically: var select = document.getElementById("MyList"); var options = ["1", "2", "3", "4", "5"]; for (var i = 0; i < options.length; i++) { var opt = ...

Failure to load image logo when refreshing the page

There's something peculiar happening in my App.vue. Imagine I have a route link, let's say it's localhost/tools or any similar route. The logo image will display on this route. Take a look at the image here https://i.stack.imgur.com/6HaXI.p ...

Error! D3.js is throwing an Uncaught TypeError because it cannot find the function .enter(...).append(...).merge

Currently, I am facing an issue while attempting to construct a table with multiple nested dropdowns using d3.js. The problem arises when switching from a newer version of d3 where my code functions flawlessly to d3.js v3. Upon replacing the newer version ...

Encountered an empty value while trying to populate a modal from JSON parsing using Swift 4

Looking to utilize Swift 4 for parsing the retrieved data below. {"bannerCategory":{"name":"","apps":[{"ImageName":"enhancedWith3dTouch"},{"ImageName":"drSeussBanner"},{"ImageName":"indieGameBanner"},{"ImageName":"clashRoyaleBanner"}],"type":""},"catego ...

traverse a PHP array with multiple dimensions using a relative path

While working on my website, I encountered an issue with reading JSON data that I'm trying to use. Fetching the data is not a problem: <?php $data = json_decode(file_get_contents('http://ddragon.leagueoflegends.com/cdn/5.2.1/data/en_US/cha ...

Unable to retrieve value from a hidden input field using JavaScript

My goal is to retrieve a value from a hidden inputbox using JavaScript. However, I am encountering issues where sometimes I receive an "undefined" error and other times there is no output at all. When I utilize alert(document.getElementById('hhh& ...

The React Material Component stubbornly resists being horizontally aligned in the Code Sandbox

Currently, I am working on getting my Material design to function properly within the CodeSandbox environment. One issue I am encountering is attempting to center it horizontally. As of now, it appears like this: To make it easier to identify its locati ...

Incorporating jQuery tooltips within a dynamically refreshing jQuery div

Having trouble with jQuery tooltips (using Tipsy) on a dynamically included page. The tooltips work well on regular pages, but when I include the page through PHP and set up auto-refresh using jQuery, the tooltips stop working properly. The issue seems to ...

How can I define the boundaries for the scrolling of a static background image?

Is there a way to limit how far a fixed background image can scroll down a page? Essentially, is it possible to change the background attachment to static when the bottom of the background image is 10px away from the bottom edge of its div container? In t ...

The chat text will automatically scroll down, displaying information loaded from the database

Is there a way to ensure that chat text always remains scrolled to the bottom of the chat? I have tried multiple tutorials and examples from Stack Overflow, but none seem to work for me. Currently, my chat text overflows the textarea when there are too m ...

Complete and automatically submit a form in a view using AngularJS

I have developed a basic AngularJS application that is functioning smoothly. Currently, I am looking to populate certain fields and submit the form directly from the view without requiring any user input. Below, you'll find some simplified JavaScrip ...

What is the proper way to use an AND operation in jQuery on multiple attributes?

I have a list of DIV tags structured as follows: <div status="1" searchText="some text">...</div> <div status="2" searchText="more text">...</div> <div status="1" searchText="even">...</div> To toggle the visibility of ...

The Protected Routes in React Router Dom persistently redirecting

I am currently implementing protected routes in my Redux and Pure React app using React Router Dom. The issue I am facing is that when I navigate to /profile/edit and then refresh the page, it automatically redirects me to /login and then to /profile. I ha ...

Dynamic TypeScript class constructor argument typing determined by user input

I am working on creating a dynamic class that can adapt its argument properties based on a certain value. To illustrate this concept, let's consider a simple example: Imagine I have a class called Customizer, and depending on the value of the mode pr ...

Surfing the web with Internet Explorer means music downloads rather than streaming

My music website functions properly, however I am experiencing issues when accessing it through Internet Explorer. The internet download manager is downloading music from the site without any problems in Chrome and Firefox. Is there a way to prevent or b ...

Steps for eliminating the chat value from an array tab in React

tabs: [ '/home', '/about', '/chat' ]; <ResponsiveNav ppearance="subtle" justified removable moreText={<Icon icon="more" />} moreProps={{ noCar ...

Tips for successfully passing an entire object in the data of a datatable column property

I am currently using Datatables version 1.10.21 and implementing ajax with the column property to generate the datatables successfully. ajax: { url: dataUrl, //using dataUrl variable dataSrc: 'data' }, co ...

What causes Firefox's CPU to spike to 100% when a slideshow begins that adjusts the width and left coordinates of certain divs?

Seeking Advice I'm in need of some help with identifying whether the code I'm working on is causing high CPU usage in Firefox or if it's a bug inherent to the browser itself. The situation is getting frustrating, and I've run out of so ...

Guide to utilizing a JWT token within an httpOnly cookie for accessing a secured API endpoint

Utilizing next.js and next-auth for user login authentication with an API. Once the login is successful, a httpOnly cookie named __Secure-next-auth.session-token is stored in the browser. The following is a sample value (not actual data): eyJhbGciOiJIUzUxM ...