Merged PR 51: Bug510保存成功後イベントで文字結合複数設定の非同期処理修正

Bug510保存成功後イベントで、文字結合の複数設定の非同期処理修正。
feat239文字結合。

Related work items: #239, #510
This commit is contained in:
Yu Wang
2024-07-17 13:28:35 +00:00
committed by Takuto Yoshida(タクト)

View File

@@ -159,32 +159,32 @@ export class StringJoinAction implements IAction{
if (!event.type.includes('success')){
//保存先フィールドに値セット:
record[this.props.saveField.code].value=saveValue;
window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。");
//window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。");
}else{
const params={
"app":event.appId,
"id":event.recordId,
"record":{[this.props.saveField.code]:{"value":saveValue}}
};
return await kintone.api(kintone.api.url('/k/v1/record',true),'PUT',params).then((resp) => {
//kintone保存先フィールド存在確認
record[this.props.saveField.code].value=saveValue;
if (event.type.includes('index')){
window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。一覧画面更新成功後自動リロードしません。必要に応じて手動リロードください。");
}else{
window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。");
}
//一覧画面更新成功後リロード:
// if (event.type.includes('index')){
// event.url = location.href.endsWith('/') || location.href.endsWith('&') ?
// location.href.slice(0, -1) :
// location.href + (location.href.includes('?') ? '&' : '/');
// }
}).catch((error) => {
event.error = 'エラーが発生しました。結合しません。システム管理者へお問合せください';
window.alert(event.error+"error message"+error);
return event;
});
//kintone async/await による非同期処理(成功イベントREST API処理時)
async function updateRecord(fieldCode:string,event:any) {
return new Promise((resolve, reject) => {
var updatedRecord = {
app: event.appId,
id: event.recordId,
record: {[fieldCode]:{"value":saveValue}}
};
kintone.api(kintone.api.url('/k/v1/record', true), 'PUT', updatedRecord, (resp) => {
resolve(resp);
}, (error) => {
reject(error);
});
});
}
//kintone保存先フィールド存在確認
record[this.props.saveField.code].value=saveValue;
//kintone async/await による非同期処理:
await updateRecord(this.props.saveField.code,event);
//一覧画面更新成功後手動リロードください:
if (event.type.includes('index')){
//window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。一覧画面更新成功後自動リロードしません。必要に応じて手動リロードください。");
window.alert("文字結合には、一覧画面更新成功後自動リロードしません。必要に応じて手動リロードください。");
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
result= {