Reputation: 25
We have a requirement where we will add multiple sections and each section with multiple widgets, i got to know we have limitation on sections as 100 per card, do we have any limitations on the widget count per card in appscript to develop gmail add-on. Ex: var card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Quick Label'); var section = CardService.newCardSection(); section.addWidget(CardService.newKeyValue().setMultiline(true).setContent("text")); section.addWidget(CardService.newKeyValue().setMultiline(true).setContent("text"));......
card.addSection(section);
card.addSection(section);
card.addSection(section);..enter code here
Please help me out on this. Thanks
Upvotes: 0
Views: 192
Reputation: 19309
There is indeed a limitation to the number of widgets you can add. At most, there can only be 100 in a card.
So, if you want to create a card with multiple sections that have multiple widgets each, you have to take into account that the product of sections and widgets per section cannot surpass 100.
As a result, if you only have one section, you can have 100 widgets there. And if you have 100 sections, there can only be one widget per section if you want them all to show up.
You can check this limitation easily by deploying this add-on and changing numSections
and numWidgets
accordingly:
function buildWidgets(e) {
var card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader()
.setTitle('Quick Label').setImageUrl('https://www.gstatic.com/images/icons/material/system/1x/label_googblue_48dp.png'));
var numSections = 10; // Change this to notice limitation
var numWidgets = 10; // Change this to notice limitation
for (var i = 0 ; i < numSections; i++) {
var tempsection = CardService.newCardSection().setHeader('Texts '+ i + 'aaaa.');
for(var j = 0; j < numWidgets; j++) {
tempsection.addWidget(CardService.newTextButton().setText("Sections num"+j).setOnClickAction(CardService.newAction().setFunctionName("test")));
}
card = card.addSection(tempsection);
}
card = card.build();
return [card];
}
I don't know why you want so many sections and widgets, but please be aware that it's considered a Best practice to keep the cards simple and without too many widgets.
I hope this is of any help to you.
Upvotes: 1