Skip to content

Instantly share code, notes, and snippets.

@tkc49
Created January 28, 2021 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkc49/2c52fdb6d090f423644c9a4d3f129b1c to your computer and use it in GitHub Desktop.
Save tkc49/2c52fdb6d090f423644c9a4d3f129b1c to your computer and use it in GitHub Desktop.
reduceの中でrecordの'種別'が'欠勤'じゃない時だけ取得日数を足す
(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