如何解决如何在加特林的foreach循环中调用资源请求?
正如我从加特林文档中正确阅读的那样,function onOpen(){
const ss = SpreadsheetApp.getActive();
const menuEntries = [];
menuEntries.push({name: 'BOSS',functionName: 'utg'});
ss.addMenu('Check and Send',menuEntries);
}
function sendSpreadsheetToPdf(sheetNumber,pdfName,email,subject,htmlbody) {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var spreadsheetId = spreadsheet.getId()
var sheetId = sheetNumber ? spreadsheet.getSheets()[sheetNumber].getSheetId() : null;
var url_base = spreadsheet.getUrl().replace(/edit$/,'');
var url_ext = 'export?exportFormat=pdf&format=pdf' //export as pdf
+ (sheetId ? ('&gid=' + sheetId) : ('&id=' + spreadsheetId))
// following parameters are optional...
+ '&size=A4' // paper size
+ '&portrait=false' // orientation,false for landscape
+ '&fitw=true' // fit to width,false for actual size
+ '&sheetnames=true&printtitle=false&pagenumbers=true' //hide optional headers and footers
+ '&gridlines=false' // hide gridlines
+ '&fzr=false'; // do not repeat row headers (frozen rows) on each page
var options = {
headers: {
'Authorization': 'Bearer ' + ScriptApp.getOAuthToken(),}
}
var response = UrlFetchApp.fetch(url_base + url_ext,options);
var blob = response.getBlob().setName(pdfName + '.pdf');
if (email) {
var mailOptions = {
attachments:blob,htmlBody:htmlbody
}
MailApp.sendEmail(
email,subject+" (" + pdfName +")","Hello Boss this is the offer for the current project",mailOptions);
}
}
function sendSheetToPdf(){ // this is the function to call
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheets()[0]; // it will send sheet 0 which is the first sheet in the spreadsheet.
// if you change the number,change it also in the parameters below
var shName = sh.getName()
sendSpreadsheetToPdf(0,shName,"email here","test email with pdf ");
}
function utg() {
var ui = SpreadsheetApp.getUi();
var sheet = SpreadsheetApp.getActive().getSheetByName("AUDIO"); //this is the sheet that the data to be checked is in
var sunCells = ["B18","B19","C23"]; // Modified
var ranges = sheet.getRangeList(sunCells).getRanges(); // Added
var res = sunCells.filter(function (_,i) {return ranges[i].isBlank()}); // Added
var col = res;
var value = SpreadsheetApp.getActiveSheet().getRange(col).getValue();
var message = 'Cell is empty ' + res + value;
var title = 'Test Send email if cell is not empty';
if (res.length > 0) {
SpreadsheetApp.getActiveSpreadsheet().toast(message,title);
} else {
sendSheetToPdf();
}
}
循环期望foreach
作为可执行表达式。
foreach(sequence,elementName){chain}对于每一个重复该链 序列中的元素,当前元素存储在 会话在elementName键下
但是,如果我想在ChainBuilder
方法中使用它,它将期望resource
s。这是我的用例:
HttpRequestBuilder
解决方法
从Gatling 3.3(以及即将推出的3.4)开始,这是不可能的。 resources
中的请求数只能是静态的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。