Event Listeners for Number Field Within a Table

Can someone please explain why this code functions perfectly for a number field that is outside of a table, but when I change the event listener field and the logged field to pertain to a field within a table, I get no results?

Snippet 1 is for a number field that is located outside of the table (field code: “test_number_field”).
Snippet 2 is for a number field that is located within a table (table field code: “garments”, number field code: “qty”).

// Snippet 1
(function() {
"use strict";

kintone.events.on('app.record.create.change.test_number_field', function(event) {
let record = event.record;
console.log(record['test_number_field']);

return event;
});
}());


// Snippet 2
(function() {
"use strict";

kintone.events.on('app.record.create.change.qty', function(event) {
let record = event.record;
console.log(record['qty']);

return event;
});
}());

Hello Ben,

In the table, the changed event seems to work and, it is possible to acquire information about the modified row.
You may check the sample code from the page below.

Acquire the changed field and row object within the table:
https://developer.cybozu.io/hc/ja/articles/201941984#step11

It seems to be not working because the value is not being output by the following process that appointed the field directly.
console.log(record[‘qty’]);

→ There is no information about ‘qty’ after ‘record.’

Please check if the event occurs by changing value within the table to refer to, like one below.

console.log(record[‘garments’]);
console.log(record[‘garments’][‘value’][0][‘value’][‘qty’]);

Hopefully, this solves the issue.

Sean

Hello Sean,

Thank you for your reply. I understand now that the console.log() call was incorrect because, as you said, there is no information about ‘qty’ after ‘record’.

But, even if the argument that is passed to console.log() is incorrect, I should still see a message in the console when the ‘qty’ field is changed, which I do not. For instance, the following code does not log anything to the console when the ‘qty’ number field is changed:

(function() {
'use strict';

kintone.events.on('app.record.create.change.qty', function(event) {
console.log("Test")

return event;
});
}());

Hello Ben,

I checked the sample code and on the console screen, “Test” was output.

<Process>

  1. Add the record, then, set the value to “qty” field within the table.
  2. Take the focus off from the “qty” field within the table.
  3. Click on F12 and check the [Console] tab.

→ I believe “Test” will be output.

There are two reasons why this could be happening,
・The “Numeric Value” field code within the table is not “qty”
・Not taking the focus off after the “qty” field has been set with a value

Now, if using the Chrome developer tool, you are able to attach the breakpoint within the “Sources” tab or debug it.
Could you check to see if the process of console.log(“Test”) is being executed?

Hopefully, this helps.

 

Sean

Hi Sean,

My apologies. I didn’t realize that there is a priority to the *.js files uploaded to an app. I moved the script file in question to the very top of the upload list and it worked. There must be code in another file that is preventing the “Test” message from logging. I will inspect further. Thank you for the detailed response and your help.