Skip to content

Instantly share code, notes, and snippets.



Created Oct 4, 2016
What would you like to do?
Array.prototype.findByPropName = function(name){
for(var i = 0; i < this.length; i++){
if(this[i].key == name) return this[i]
return {value: undefined};
function onOpen() {
function addMenu() {
.addItem('Проверить', 'checkOrders')
function checkOrders() {
var sh=SpreadsheetApp.getActive().getActiveSheet();
var numRows=sh.getDataRange().getNumRows();
for (var index=2; index<=numRows; index++) {
var orderNum=sh.getRange(index, 4).getValue();
var orderDate=new Date(sh.getRange(index, 5).getValue());
var query="properties has {key='orderNum' and value='"+orderNum+"' and visibility='PUBLIC'}";
var files=Drive.Files.list({q: query});
for (var i=0; i<files.items.length; i++) {
var currfile=files.items[i];
var fileUrl=currfile.alternateLink;
var savedDate=new Date('orderDate').value);
if ((orderDate.getDate()==savedDate.getDate())&&(orderDate.getMonth()==savedDate.getMonth())&&(orderDate.getFullYear()==savedDate.getFullYear()))
sh.getRange(index, 9).setValue(fileUrl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment