# Update table ⇒ Update corresponding record of another application

**URL:** <https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364>\
**Category:** General\
**Created:** [November 25, 2020, 9:34am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364 "2020-11-25T09:34:13Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [November 25, 2020, 9:34am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/1 "2020-11-25T09:34:13Z")

</div>

Hello Dev teams, can i ask this one!&nbsp;

When I press the save button, the data is transferred to another app at the edit event.

so, i want to ask

The error appears as follows in the line id (187), please tell me why the error, thank you very much.

![](https://developer.kintone.io/hc/user_images/ISLQ533HN5pslbkFRLGy_Q.png)

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [November 25, 2020, 9:38pm UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/2 "2020-11-25T21:38:18Z")

</div>

Can you tell me what kind of error are you seeing?

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [November 26, 2020, 12:44am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/3 "2020-11-26T00:44:08Z")

</div>

Hi&nbsp; **Yuzo Arai,**

&nbsp;When I press the save button for the first time this error occurs.

Thank you so much. ![](https://developer.kintone.io/hc/user_images/WaPZ41iLw-t3Jkec-hGtPA.png)

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [November 27, 2020, 3:35pm UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/4 "2020-11-27T15:35:08Z")

</div>

Hi NDC,

From the screenshot,

“Cannot read property ‘value’ of undefined” error

on the 187th line,

&nbsp;

id : row.value.id.value

&nbsp;

seems to be caused by not getting the value.

Please check if the description of row.value.id.value is correct.

&nbsp;

However, as other phenomena could occur, if you run into other problems, please provide us with the source code, if possible.

&nbsp;

Hopefully, this helps.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [November 30, 2020, 7:26am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/5 "2020-11-30T07:26:05Z")

</div>

Hi Sean Tachibana,

Have a nice day.&nbsp;

As I answered Mr Yuzo Arai, the data after pressing the save button is still correctly returned when I debug (console) ,. but the returrn line is undefined,  
How do I try, and how else to debug?

Would you please do a demo app like me, 1 property for the header and 1 table of 2 properties. just 1 or 2 properties help me to unpack the edit function.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 1, 2020, 5:00am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/6 "2020-12-01T05:00:38Z")

</div>

Hi Sean Tachibana,

Hi Yuzo Arai,

I’m sorry for bothering you both. I will stop here …

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 1, 2020, 11:29pm UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/7 "2020-12-01T23:29:00Z")

</div>

Hello NDC,

When I debugged the script by doing the following:

```
console.log(row);
console.log(row.value);
console.log(row.value.id);
console.log(row.value.id.value);
return {
id: row.value.id.value,
record: row.value
};

```

it gave me an “undefined” error in the third row.  
**console.log(row.value.id);**  
This means that the id does not exist. And this is why you are experiencing the error.

I experimented with the script myself,  
and when I put a fixed value like the following,  
I didn’t see any error:

```
return {
id: 1,
record: row.value
};

```

Try to fix your script in a way that specifies a record  
that you want to update.

If you need help on debugging,  
please use the following page as your help:

**Kintone Developer Program - Debugging tips for Kintone JS**  
[https://developer.kintone.io/hc/en-us/articles/115003211768-Debugging-tips-for-Kintone-JS](https://developer.kintone.io/hc/en-us/articles/115003211768-Debugging-tips-for-Kintone-JS)

For you reference, I will leave the script that I used when I was testing below:

```
(function() {
"use strict";

// 更新時の処理
kintone.events.on("app.record.edit.submit.success", function(event) {

var postApp = 5407; // 別アプリのID
var recId = event.recordId; // テーブルを登録したレコードを更新するためのID
var subTable = 'yaoya_subtable'; //サブテーブルのフィールドコード
var headers = [ //コピーするサブテーブル外のフィールドのフィールドコード
'day_yaoya',
'aaa'
];

var record = event.record;

console.log(event.record[subTable].value.map(function (row) {
headers.forEach(function (header) {
row.value[header] = event.record[header];
});
return row.value;
}))

return kintone.api(kintone.api.url('/k/v1/records', true), 'PUT', {
app: postApp,
records:
event.record[subTable].value.map(function (row) {
headers.forEach(function (header) {
row.value[header] = event.record[header];
});

console.log(row);
console.log(row.value);
console.log(row.value.id);
// console.log(row.value.id.value);

return {
id: 1,
record: row.value
};

})
});
});

})();
```

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 2, 2020, 1:09am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/8 "2020-12-02T01:09:20Z")

</div>

Hello Yuzo Arai,

I already know my error is because the two apps don’t have the same id, it is always skewed at birth, because on App A side if there are 2,3,4 rows in table Whereas side id has only 1, then on the B side it will generate 2,3,4 id records, so always deviate, will not be able to correct. It can only be edited when there is 1 row in a table.  
as shown below:

![](https://developer.kintone.io/hc/user_images/UTmVMC0SYyA1tPzm-pnxEA.png)

Would you please give me any suggestion to solve this place?

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 3, 2020, 4:31pm UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/9 "2020-12-03T16:31:27Z")

</div>

Hi NDC,

&nbsp;

I have checked the process you provided us previously, and the process generates a request by dividing the table rows into records.

Also, since you specified PUT in the previous version, no records should be added.

Therefore, since only the API is switched to POST and have not changed the request generating process, the table rows are likely separated and added by records.

&nbsp;

It is possible to register a single record containing a multi-row table by executing the following request.

&nbsp;

```
var parm = {

"app":4459,

"record":{

"Table": {

"value":[

{

"value":{

"Product NameA":{

"value":"a"

},

"Amount of money A":{

"value":"111"

},

"Within the drop-down period":{

"value":"52Period"

}

}

},

{

"value":{

"Product NameA":{

"value":"bb"

},

"Amount of money A":{

"value":"222"

},

"Within the drop-down period":{

"value":"58Period"

}

}

},

{

"value":{

"Product NameA":{

"value":"cc"

},

"Amount of money A":{

"value":"333"

},

"Within the drop-down period":{

"value":"12Period"

}

}

}

]

},

},

};

kintone.api(

'/k/v1/record',

'POST',

parm,

function(event){console.log(event);},

function(err){console.log(err);}

);

```

&nbsp;

You can also update the table for the record specified in “id” with the following request.

&nbsp;

```
var parm = {

"app":4459,

"id":1,

"record":{

"Table": {

"value":[

{

"value":{

"Product NameA":{

"value":"a"

},

"Amount of money A":{

"value":"111"

},

"Within the drop-down period":{

"value":"52Period"

}

}

},

{

"value":{

"Product NameA":{

"value":"bb"

},

"Amount of money A":{

"value":"222"

},

"Within the drop-down period":{

"value":"58Period"

}

}

},

{

"value":{

"Product NameA":{

"value":"cc"

},

"Amount of money A":{

"value":"333"

},

"Within the drop-down period":{

"value":"12period"

}

}

}

]

},

},

};

kintone.api(

'/k/v1/record',

'PUT',

parm,

function(event){console.log(event);},

function(err){console.log(err);}

);

```

Field Types:

[https://developer.kintone.io/hc/en-us/articles/212494818-Field-Types](https://forum.kintone.dev/hc/en-us/articles/212494818-Field-Types)

&nbsp;

Based on the above requests, please review the APIs to be executed and how requests are made.

If not, we would like to know how you would like it to work and the details of the current process you are describing.

&nbsp;

Hopefully, this helps.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 4, 2020, 3:18pm UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/10 "2020-12-04T15:18:55Z")

</div>

Hi Sean Tachibana,

I have fixed the above error, thanks for your advice.

Would you mind if I could ask more?

\*\*\*\* How do i return the 2nd&nbsp; table?  
 ![](https://developer.kintone.io/hc/user_images/MFne4aDV3NyMEzUuOhvooA.png)

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 8, 2020, 1:10am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/11 "2020-12-08T01:10:31Z")

</div>

Hello NDC,

I’m not quite understanding what you mean by 2nd table.  
Can you post the screenshots of your app that clarifies more about what you’re trying to do?

Thank you

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 8, 2020, 7:38am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/12 "2020-12-08T07:38:20Z")

</div>

Hi Yuzo Arai,

I have chosen another way.

Would you mind if I could ask more?

I want to show the error as&nbsp;the figure I provide when i handle checking :

With my code as below, How do I handle it like the figure I provide?

&nbsp;

![](https://developer.kintone.io/hc/user_images/g-nnUK-Zioupq4MMZCrUSw.png)

&nbsp;

(function () {  
“use strict”;

// 更新時の処理  
kintone.events.on(“app.record.edit.submit”, function (event) {  
var record = event.record;  
var subTable = record[‘yaoya\_subtable’].value;  
//var required\_id = record[‘id’],  
var msgErr\_ary = [];  
var last\_element = subTable[subTable.length - 1];  
var first\_element = subTable[0];  
var elStatus = kintone.app.getFieldElements(‘id’);  
var fontColorRed = “#ff0000”;  
for (var i = 0; i \< subTable.length; i++) {  
if (subTable[i].value.id.value != 0) {  
subTable[i].value.id.disabled = true;  
}  
else  
if (subTable[i].value.id.value == 0) {  
subTable[i].value.id.disabled = false;  
}  
}

if (first\_element.value.id.value != 0) {  
for (var i = 0; i \< subTable.length; i++) {  
if (subTable[i].value.id.value == 0) {  
subTable[i].value.id.style.background = fontColorRed;  
msgErr\_ary.push(subTable[i].value.itemA.value);  
}  
}  
}

if (first\_element.value.id.value != 0) {  
if (last\_element.value.id.value != 0) {  
console.log(“Check ok bro!”);  
}  
}

var msg\_str = msgErr\_ary.join(’ and ');  
event.error = msg\_str;  
return event;  
});  
})();

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 9, 2020, 7:38pm UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/13 "2020-12-09T19:38:07Z")

</div>

Hi NDC,

I found an article that might fit the description.  
Please take a look and see if it accomplishes the desired process.

This sample runs validation checks for values inside tables when saving the record.

Validation checks in tables:  
[https://developer.kintone.io/hc/en-us/articles/115005616728-Validation-checks-in-tables](https://developer.kintone.io/hc/en-us/articles/115005616728-Validation-checks-in-tables)

Hopefully, this helps.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [December 10, 2020, 1:17am UTC](https://forum.kintone.dev/t/update-table-update-corresponding-record-of-another-application/364/14 "2020-12-10T01:17:16Z")

</div>

Hi Sean Tachibana/ Hello Yuzo Arai/

i Did it, tks you/. have a nice day.
