diff --git a/plugin/kintone-addins/src/actions/insert-value.ts b/plugin/kintone-addins/src/actions/insert-value.ts index 9670d84..ef7de35 100644 --- a/plugin/kintone-addins/src/actions/insert-value.ts +++ b/plugin/kintone-addins/src/actions/insert-value.ts @@ -50,7 +50,7 @@ export class InsertValueAction implements IAction{ blankCheck = inputValueArray[i].match(/^(\s| )*$/);//空文字・半角スペース・タブ文字・改行・改ページ・全角スペース } - if(blankCheck !== null){ + if(blankCheck !== undefined){ //空白文字を空白文字が非対応のフィールドに挿入しようとしている場合、例外を発生させる if(fieldType === "NUMBER" || fieldType === "DATE" || fieldType === "DATETIME" || fieldType === "TIME" || fieldType === "USER_SELECT" || fieldType === "ORGANIZATION_SELECT" || fieldType === "GROUP_SELECT" || fieldType === "RADIO_BUTTON" || fieldType === "DROP_DOWN" || fieldType === "CHECK_BOX" || fieldType === "MULTI_SELECT"){ @@ -82,7 +82,7 @@ export class InsertValueAction implements IAction{ } } - if(blankCheck !== null){ + if(blankCheck !== undefined){ //空白文字を空白文字が非対応のフィールドに挿入しようとしている場合、例外を発生させる if(fieldType === "NUMBER" || fieldType === "DATE" || fieldType === "DATETIME" || fieldType === "TIME" || fieldType === "USER_SELECT" || fieldType === "ORGANIZATION_SELECT" || fieldType === "GROUP_SELECT" || fieldType === "RADIO_BUTTON" || fieldType === "DROP_DOWN" || fieldType === "CHECK_BOX" || fieldType === "MULTI_SELECT"){ @@ -487,9 +487,11 @@ export class InsertValueAction implements IAction{ } //文字列型のフィールド以外に、空白文字の変数の値を挿入する場合、エラーを出す - if(fieldType !== "SINGLE_LINE_TEXT" && fieldType !== "MULTI_LINE_TEXT" && fieldType !== "RICH_TEXT" && fieldType !== "LINK" - && objectValue === null){ - throw new Error("「"+fieldCode+"」"+"フィールドに挿入しようとした変数は、値がnullのため、処理を中断しました。"); + if(objectValue === "" ){ + if(fieldType === "NUMBER" || fieldType === "DATE" || fieldType === "DATETIME" || fieldType === "TIME" || fieldType === "USER_SELECT" + || fieldType === "ORGANIZATION_SELECT" || fieldType === "GROUP_SELECT" || fieldType === "RADIO_BUTTON" || fieldType === "DROP_DOWN" || fieldType === "CHECK_BOX" || fieldType === "MULTI_SELECT"){ + throw new Error("「"+fieldCode+"」"+"フィールドに挿入しようとした変数は、値がnullのため、処理を中断しました。"); + } } //オブジェクト変数の場合、プロパティを取得し、何のオブジェクト変数か判断する @@ -625,10 +627,10 @@ export class InsertValueAction implements IAction{ //条件式の結果がtrueかつ挿入する値が変換できた場合、フィールド(ラジオボタン・ドロップダウン・チェックボックス・複数選択・文字列一行・文字列複数行・リッチエディタ・数値・日付・日時・時刻)にセット if(conditionResult){ //条件式の結果がtureかつ、値を正しい形式に変換できた場合、フィールドに値をセットする - if(correctFormattedValue !== null && correctFormattedValue !== undefined){ + if(correctFormattedValue !== undefined){ event.record[fieldCode].value = correctFormattedValue; //条件式の結果がtureかつ、値を正しい形式(配列)に変換できた場合、フィールドに値(配列)をセットする - }else if(correctValues.length > 0 && correctValues !== null && correctValues !== undefined){ + }else if(correctValues.length > 0 || correctValues !== undefined){ event.record[fieldCode].value = correctValues; } } @@ -651,24 +653,23 @@ export class InsertValueAction implements IAction{ } //条件式の結果がtrueかつ挿入する値が変換できた場合、フィールド(ラジオボタン・ドロップダウン・チェックボックス・複数選択・文字列一行・文字列複数行・リッチエディタ・数値・日付・日時・時刻)にセット - if(conditionResult && (correctFormattedValue || correctValues)){ + if(conditionResult){ //条件式の結果がtureかつ、値を正しい形式に変換できた場合、フィールドに値をセットする - if(correctFormattedValue){ + if(correctFormattedValue !== undefined){ event.record[fieldCode].value = correctFormattedValue; //条件式の結果がtureかつ、値を正しい形式(配列)に変換できた場合、フィールドに値(配列)をセットする - }else if(correctValues.length > 0){ + }else if(correctValues.length > 0 || correctValues !== undefined){ event.record[fieldCode].value = correctValues; } } //kintone async/await による非同期処理(レコード更新) - if(correctFormattedValue){ + if(correctFormattedValue !== undefined){ await updateRecord(fieldCode,event,correctFormattedValue); //条件式の結果がtureかつ、値を正しい形式(配列)に変換できた場合、フィールドに値(配列)をセットする - }else if(correctValues.length > 0){ + }else if(correctValues.length > 0 || correctValues !== undefined){ await updateRecord(fieldCode,event,correctValues); } - // await updateRecord(fieldCode,event,correctFormattedValue); }; result= {