kintone.app.record.get(); not working

The below code seems to be quite obvious, but it’s not working on my kintone app…not really understanding why:

(function() {
    “use strict”;
    kintone.events.on(‘app.record.edit.show’, function(event) {
    var details= kintone.app.record.get();
    console.log(details);
    return event;
    });
})();

The error in the console keeps showing “Uncaught Error: You cannot call kintone.app.record.get() in handler or during processing a handler.” - a bit confused why this error is being shown.

Hello Akira!

Like the error says, this is because of kintone.app.record.get (also kintone.mobile.app.record.get) cannot be called in the kintone.events.on the handler. This is also explained in the help page (the link is below). If you would like to obtain a record data in the event handler, you must use the event object.

 kintone developer network - Get Record
 https://developer.kintone.io/hc/en-us/articles/213148957-Get-Record

Oh, sorry, my bad…yes, of course…got too stuck in my scripts and I didn’t realize this simple mistake. Thanks for pointing that out.

It works perfectly with the below code :slight_smile:

(function() {
    “use strict”;
    kintone.events.on(‘app.record.edit.show’, function(event) {
        var details= event.appId;
        console.log(details);
        return event;
    });
})();

Actually I don’t really need to return the event either for this code