How to use setFieldShown JS API?

Hello,

I am coding inside kintone.events.on to hide (not display) a Text field.
The field’s name is set to title.

Here is my current attempt at using the kintone.app.record.setFieldShown() API:

kintone.app.record.setFieldShown(‘title’, false);

What am I doing wrong?

Hello @Jayron_Rosel ,

Please verify that you set the target field’s field code to title as well.

To use the API, follow this template:

kintone.app.record.setFieldShown(fieldCode, isShown)

Here is an example:

The field code is set to Text.

kintone.events.on('app.record.detail.show', function(event) {
  kintone.app.record.setFieldShown('Text', false);
});

Hello @Genji

Here is more information regarding my situation.

App Setup

The Text field’s field code is set to title.

Script

kintone.events.on('app.record.detail.show', function(event) {
  kintone.app.record.setFieldShown('title', false);
});

Current Result

Despite the script, the text field is still being shown on the record detail view:


What am I doing wrong?

@Jayron_Rosel , your function in your script is not being called.

The code snippet from the kintone.app.record.setFieldShown() API Doc is just a function. You would need to include a line to call the function for the field to be hidden.

Solution

(function() {
  kintone.events.on('app.record.detail.show', function(event) {
    kintone.app.record.setFieldShown('title', false);
  });
})();

Recommendations

We highly recommend you go through our many tutorials to better understand what it takes to build Kintone customizations.

Here are a few related tutorials:

We recommend installing and using JSEdit Plug-in for a simpler time building Kintone Customizations.
It is a Kintone plug-in that allows users to edit JavaScript and CSS codes easily on the Kintone platform.

jsedit_animation.gif