Created
January 28, 2021 16:23
-
-
Save tkc49/2c52fdb6d090f423644c9a4d3f129b1c to your computer and use it in GitHub Desktop.
reduceの中でrecordの'種別'が'欠勤'じゃない時だけ取得日数を足す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
kintone.events.on([ | |
'app.record.edit.submit' | |
], function (event) { | |
return new kintone.Promise(function(resolve){ | |
RelatedRecordsFieldManager.prototype.getFieldProperties().then(function(){ | |
(new RelatedRecordsFieldManager('取得履歴')).getRecords(event.record).then(function(records){ | |
event.record.totalAmount2.value = records.reduce(function (sum, record) { | |
if (record.種別.value !== '欠勤') { | |
return sum + Number(record.取得日数.value); | |
} else { | |
return sum | |
} | |
}, 0); | |
console.log(event); | |
resolve(event); | |
}); | |
}); | |
}); | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment