setFieldShown not instantly work

Dear Developers

Let’s say I put a code inside kintone.events.on, and that code is simply, to hide/not to display a one field (a text box), let’s name it “No_ID”

My code goes below, something like this:

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

Then, after I tested the code, it works, but, it shown some delay like it’s not instantly hidden, for about 1 sec or less I’ve seen the page appear with field No_ID still there and after 1 sec passed it disappear

I’m glad it disappear but my client asked me that they want me to make it instantly disappear without any delay because during that moment one may take a screenshot

Please help, any answer would be appreciated, thank you very much

If you do not need to show the field to certain users, it might be best to simply set up permission for each field at App setting from Kintone basic feature.

▼ Setting Permission for Fields

https://get.kintone.help/k/en/user/app_settings/rights/field_rights.html

However, if you need to customize with JS, you might want to reconsider what is causing the delay in your current coding. For example,  whether the executed API process was working with an immediate function or not.

I also think in case of heavy processing or pre-processing of the synchronization process, there might be a slight delay in processing.

As another possibility to solve your issue, you might want to use a loading icon, spinner, with the spin.js library. While the spinner is working, you may be able to show some kind of a dialog that covers the entire window to hide the page until the API processing is complete.

This website below explains how to utilize spin.js.(sorry but without a dialog to cover the entire window as I suggested)

▼ Show/hide a spinner with spin.js

https://developer.kintone.io/hc/en-us/articles/115007823867-Show-hide-a-spinner-with-spin-js

Hope it helps.

Afief, please note that kintone.app.record.setFieldShown(‘No_ID’, false); will only visually hide the data.

Other viewers will be able to view the field if they type 
kintone.app.record.setFieldShown(‘No_ID’, true);  or kintone.app.record.get();  in the console.

As Junko suggests, if it’s possible to set up the Field Permission in the App settings, that would be the best option. Values inside fields that are hidden in this way cannot be retrieved by the above methods.

I see, I think I understand that it’s much better if we play around with permission settings if we want a certain field to be completely disappear from certain users, I may do something on customizing the javascript if for example what I want to seek on permission settings are not available there

Anyway, I appreciate the reply, thank you very much