diff --git a/plugin/kintone-addins/src/actions/insert-value.ts b/plugin/kintone-addins/src/actions/insert-value.ts index 1fa0335..9670d84 100644 --- a/plugin/kintone-addins/src/actions/insert-value.ts +++ b/plugin/kintone-addins/src/actions/insert-value.ts @@ -75,9 +75,11 @@ export class InsertValueAction implements IAction{ checkVariableValueBlank(fieldType :string | undefined,inputValueArray :any,fieldCode :string,fieldRequired :boolean | undefined,event :any): boolean{ let blankCheck; - //正規表現チェック - for(let i =0;i { return path.split(".").reduce((o, k) => (o || {})[k], obj); }; - //オブジェクト変数で、値の指定がある場合は、変数名のみ取得 var variablesName = fieldValue.substr(0, fieldValue.indexOf('.')); if(variablesName){ @@ -486,6 +486,12 @@ export class InsertValueAction implements IAction{ objectValue = getContextVarByPath(context.variables,fieldValue) } + //文字列型のフィールド以外に、空白文字の変数の値を挿入する場合、エラーを出す + if(fieldType !== "SINGLE_LINE_TEXT" && fieldType !== "MULTI_LINE_TEXT" && fieldType !== "RICH_TEXT" && fieldType !== "LINK" + && objectValue === null){ + throw new Error("「"+fieldCode+"」"+"フィールドに挿入しようとした変数は、値がnullのため、処理を中断しました。"); + } + //オブジェクト変数の場合、プロパティを取得し、何のオブジェクト変数か判断する if(objectValue !== null && typeof objectValue === 'object'){ let objectProperties=[] @@ -510,8 +516,8 @@ export class InsertValueAction implements IAction{ fieldValueArray[0] = variableValue; } - //変数がfieldValueArrayに代入できなかった場合は、エラーを出す - if(objectValue === undefined && fieldValueArray === undefined){ + //変数がfieldValueArrayに代入できなかった場合、エラーを出す + if(fieldValueArray === undefined){ throw new Error("「"+fieldCode+"」"+"フィールドに入れようとした変数は、無効な入力形式です。"); } @@ -656,7 +662,13 @@ export class InsertValueAction implements IAction{ } //kintone async/await による非同期処理(レコード更新) - await updateRecord(fieldCode,event,correctFormattedValue); + if(correctFormattedValue){ + await updateRecord(fieldCode,event,correctFormattedValue); + //条件式の結果がtureかつ、値を正しい形式(配列)に変換できた場合、フィールドに値(配列)をセットする + }else if(correctValues.length > 0){ + await updateRecord(fieldCode,event,correctValues); + } + // await updateRecord(fieldCode,event,correctFormattedValue); }; result= {