用于Google表格的脚本,它将Google表单提供的时间戳转换为6-8位数字

问题描述 投票:0回答:1

GoogleForm是用于产品库存的。我以全职志愿者的身份在Food Rescue非营利组织工作,对不起,我很抱歉。我已经制作了一个记录货盘信息的表格,并且我想使用时间戳生成一个6位数字(手指交叉),我将其用作“文本代码”和“ #boxesonpallet”之间的“时间戳” namedValues可安装触发器?我发现(并希望可以更改)为

{'名字':['jane'],'时间戳':['6/7/2015 20:54:13'],'姓氏':[doe]`}

无论如何,我希望在提交时计算出该数字? (还必须学习如何操作),然后像这样使用它...

{'文本代码':['UHTMILK'],'6位数字':['671523'],'#boxesonpallet':[168]`}

然后将其发送回给我,这样我就可以将代码写在我的托盘上,然后移到下一个。

[显然,我将不得不学习如何获取表单响应表上的其余数据,并将其用于其他许多目的,但是目前要花20个小时来盘点,填写订单和重新库存,我是唯一一家拥有叉车牌照的卡车,现在我们每周要向其他慈善组织运送20个奇数个托盘,这简直太疯狂了。

你们能帮我吗?

google-apps-script google-sheets onsubmit
1个回答
0
投票
function sixdigitcodefordate() {
  const  c=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
  let html="";
  let chr={};
  c.forEach(function(ch,i){chr[i]=ch;})
  let t=Math.pow(62,1);
  let ts=Utilities.formatDate(new Date(),Session.getScriptTimeZone(),"MM/dd/yyyyy HH:mm:ss")
  let dv=new Date().valueOf()/1000;
  let d5=Math.floor(dv/Math.pow(t,5));
  let r5=dv%Math.pow(t,5);
  let d4=Math.floor(r5/Math.pow(t,4));
  let r4=r5%Math.pow(t,4);
  let d3=Math.floor(r4/Math.pow(t,3));
  let r3=r4%Math.pow(t,3);
  let d2=Math.floor(r3/Math.pow(t,2));
  let r2=r3%Math.pow(t,2);
  let d1=Math.floor(r2/Math.pow(t,1));
  let r1=r2%Math.pow(t,1);
  let d0=Math.floor(r1/Math.pow(t,0));

  html+=Utilities.formatString('radix:%s<br />TimeStamp:%s<br />Code:%s%s%s%s%s%s',t,ts,chr[d5],chr[d4],chr[d3],chr[d2],chr[d1],chr[d0])

  SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), "Display");
}

对话框输出:

enter image description here

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.