回答編集履歴
5
デバッグ用コードに修正
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
const today = new Date();
|
13
13
|
// 当日で未確認の行を抽出(日付列=B列、空欄チェック列=E列)
|
14
14
|
const records = getUncheckedRecords(values, today, 2, 5);
|
15
|
-
if (records
|
15
|
+
if (records.length === 0) {
|
16
16
|
console.log('条件にあてはまる行はありませんでした。');
|
17
17
|
return;
|
18
18
|
}
|
@@ -32,8 +32,22 @@
|
|
32
32
|
* 確認列が空欄であるデータ(2次元配列)
|
33
33
|
*/
|
34
34
|
function getUncheckedRecords(sourceData, targetDate, dateColumn, checkColumn) {
|
35
|
+
console.log(`targetDate=${targetDate}`);
|
36
|
+
console.log(`Type of targetDate= ${Object.prototype.toString.call(targetDate)}`);
|
37
|
+
console.log(`dateColumn=${dateColumn}`);
|
38
|
+
console.log(`checkColumn=${checkColumn}`);
|
39
|
+
console.log(sourceData[0].length);
|
35
|
-
return sourceData.filter(row => {
|
40
|
+
return sourceData.filter((row, i) => {
|
41
|
+
let srcMonth = '';
|
42
|
+
try{
|
36
|
-
|
43
|
+
srcMonth = row[dateColumn - 1].getMonth();
|
44
|
+
}catch(e) {
|
45
|
+
console.log(`i= ${i}`);
|
46
|
+
console.log(`row[dateColumn - 1]= ${row[dateColumn - 1]}`);
|
47
|
+
console.log(`Type of row[dateColumn - 1]= ${Object.prototype.toString.call(row[dateColumn - 1])}`);
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
|
37
51
|
const srcDate = row[dateColumn - 1].getDate();
|
38
52
|
const orgMonth = targetDate.getMonth();
|
39
53
|
const orgDate = targetDate.getDate();
|
@@ -41,7 +55,7 @@
|
|
41
55
|
row[checkColumn - 1] === '') {
|
42
56
|
return true;
|
43
57
|
}
|
44
|
-
})
|
58
|
+
});
|
45
59
|
}
|
46
60
|
```
|
47
61
|
|
4
test
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
const values = sht.getRange(3, 1, lastRow - 2, sht.getLastColumn()).getValues();
|
12
12
|
const today = new Date();
|
13
13
|
// 当日で未確認の行を抽出(日付列=B列、空欄チェック列=E列)
|
14
|
-
const records = getUncheckedRecord(values, today, 2, 5);
|
14
|
+
const records = getUncheckedRecords(values, today, 2, 5);
|
15
15
|
if (records[0].length === 0) {
|
16
16
|
console.log('条件にあてはまる行はありませんでした。');
|
17
17
|
return;
|
@@ -31,7 +31,7 @@
|
|
31
31
|
* @return {Number[][]} 指定した日付(targetDate )にあてはまるレコードのうち、
|
32
32
|
* 確認列が空欄であるデータ(2次元配列)
|
33
33
|
*/
|
34
|
-
function getUncheckedRecord(sourceData, targetDate, dateColumn, checkColumn) {
|
34
|
+
function getUncheckedRecords(sourceData, targetDate, dateColumn, checkColumn) {
|
35
35
|
return sourceData.filter(row => {
|
36
36
|
const srcMonth = row[dateColumn - 1].getMonth();
|
37
37
|
const srcDate = row[dateColumn - 1].getDate();
|
3
test
CHANGED
@@ -28,7 +28,8 @@
|
|
28
28
|
* @param {Date} targetDate :検索する日付
|
29
29
|
* @param {Number} dateColumn :sourceData のうち日付列が左から何列目か(1 始まり)
|
30
30
|
* @param {Number} checkColumn :sourceData のうち空欄を確認する列が左から何列目か(1 始まり)
|
31
|
-
* @return {Number[][]} 指定した日付
|
31
|
+
* @return {Number[][]} 指定した日付(targetDate )にあてはまるレコードのうち、
|
32
|
+
* 確認列が空欄であるデータ(2次元配列)
|
32
33
|
*/
|
33
34
|
function getUncheckedRecord(sourceData, targetDate, dateColumn, checkColumn) {
|
34
35
|
return sourceData.filter(row => {
|
2
test
CHANGED
@@ -32,7 +32,6 @@
|
|
32
32
|
*/
|
33
33
|
function getUncheckedRecord(sourceData, targetDate, dateColumn, checkColumn) {
|
34
34
|
return sourceData.filter(row => {
|
35
|
-
|
36
35
|
const srcMonth = row[dateColumn - 1].getMonth();
|
37
36
|
const srcDate = row[dateColumn - 1].getDate();
|
38
37
|
const orgMonth = targetDate.getMonth();
|
1
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
下記のようなコード
|
1
|
+
下記のようなコードを追加します。
|
2
2
|
別途、check 関数を毎日8:45に実行するようにトリガーを使って設定します。
|
3
3
|
|
4
4
|
```js
|