外部関数との連携
外部JSでカスタム計算を行い、結果をフィールドにセットする方法です。
ステップ1: カスタム関数を登録
Section titled “ステップ1: カスタム関数を登録”kintone JSカスタマイズとして以下を追加します:
window.vcPlugin = window.vcPlugin || {};window.vcPlugin.callFunction = window.vcPlugin.callFunction || {};
window.vcPlugin.callFunction.calcBusinessDays = function(arg) { const start = new Date(arg.startDate); const end = new Date(arg.endDate); let count = 0; const current = new Date(start); while (current <= end) { const day = current.getDay(); if (day !== 0 && day !== 6) count++; current.setDate(current.getDate() + 1); } return count;};ステップ2: Visual Customize から呼び出し
Section titled “ステップ2: Visual Customize から呼び出し”ルール: フィールド変更時(終了日)├── callFunction│ ├── functionName: calcBusinessDays│ ├── inputMode: value│ ├── argument: {"startDate":"{{field:開始日}}","endDate":"{{field:終了日}}"}│ └── resultKey: businessDays└── setFieldValue ├── targetField: 営業日数 └── value: {{result:businessDays}}