在一次通话中设置一批家长/同龄人 [英] Setting a batch of parents/sibblings in one call

查看:142
本文介绍了在一次通话中设置一批家长/同龄人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Google脚本,该脚本自动将Google Spreadsheet写入Smartsheet,但由于父母/同龄人已经格式化,不需要手动降级,因为我已经必须在电子表格中通过编号列进行操作。



我设法写入了Smartsheet,但我似乎无法弄清楚如何发送一批具有父母/同居者集合的(600+)行,这是在同一个urlFetch调用。



有些问题应该解决我的问题:

是否可以确定/指定我要包含的rowId?



是否可以在提供行时设置parentRowNumber?



是否可以通过其他方式在不知道rowId的情况下批量插入父行?

由于我没有找到[google-这里是如何插入一行(工作代码):

  function adcionarLinhaSmartSheet (){
//静态测试
var rows = [];
rows [0] = {};
rows [0] .cells = [];
rows [0] .cells [0] = {};
rows [0] .cells [0] .columnId =[ROW_ID];
rows [0] .cells [0] .value = 14;
rows [0] .cells [0] .strict = false;

var payload = {toBottom:true,rows:rows};

var dadosEnviar = {headers:{Authorization:Bearer [ACCESS_TOKEN],content-type:application / json},Method:post,payload:JSON .stringify(有效载荷)};

var planilhaSmart = UrlFetchApp.fetch(https://api.smartsheet.com/1.1/sheet/[SHEET_ID]/rows,dadosEnviar);
}


解决方案

向Smartsheet API发送单个POST,但该调用中的所有行将添加到工作表中相同的heirachal级别。因此,要使用具有父/子关系的行创建工作表,您可以执行以下操作:首先,进行一次调用,以将所有父级别行插入工作表。然后,使用新创建的行的rowIds,进行额外的调用,以POST为每个父级的所有子级行。您需要为每个父行的一组子行分别调用。


I'm building an Google Script that automatically writes a Google Spreadsheet to Smartsheet, but with the parents/sibbling already formated, no need for manual indeting, since I already have to do this in the Spreadsheet, trough a numbered column.

I managed to write to the Smartsheet, but I can't seem to figure out how to send a batch (600+) of lines with parents/sibblings set, which are in the same urlFetch call.

Some questions which should solve my problem:

Is it possible to determine/specify the "rowId" that I'm about to include?

Is it possible to set "parentRowNumber" when providing the row?

Is it possible any other way to batch insert rows with parents without knowing the "rowId"?

Since I haven't found [google-apps-script] + [smartsheet-api] here yet, here's how to insert a row (working code):

function adcionarLinhaSmartSheet(){
  //Static for testing
  var rows = [];
  rows[0] = {};
  rows[0].cells = [];
  rows[0].cells[0] = {};
  rows[0].cells[0].columnId = "[ROW_ID]";
  rows[0].cells[0].value = 14;
  rows[0].cells[0].strict = false;

  var payload = {"toBottom":true, "rows":rows};

  var dadosEnviar = {headers:{Authorization:"Bearer [ACCESS_TOKEN]", "content-type":"application/json"}, "Method":"post", "payload":JSON.stringify(payload)};

  var planilhaSmart = UrlFetchApp.fetch("https://api.smartsheet.com/1.1/sheet/[SHEET_ID]/rows", dadosEnviar);
}

解决方案

You can insert multiple rows with a single POST to the Smartsheet API, but all the rows in that call will be added at the same heirachal level in your sheet. So, to create a sheet using rows with parent/children relationships you could do the following:

First, make one call to insert all the parent level rows into your sheet.

Then, using the rowIds of the newly created rows, make additional calls to POST all the children rows for each parent. You'll need to make a separate call for each parent row's group of children rows.

这篇关于在一次通话中设置一批家长/同龄人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆