How to block Kintone App operations if the external API call returns a false response?

Hello @Hoang_Viet ,

Since app.record.index.show is indeed the earliest event when entering apps, you can initially hide records by manipulating the DOM and then show the content based on the response. It's important to note that Kintone allows developers to customize its UI through JavaScript. However, there can be cases where regressions occur after Kintone updates.

This isn't perfect, but here's a sample script that demonstrates how to hide/show content by pressing buttons in the header:

(function() {
    'use strict';

    // Function to hide the app content
    function hideAppContent() {
        const appContent = document.querySelector('.contents-gaia');
        if (appContent) {
            appContent.style.display = 'none';
        }
    }

    // Function to show the app content
    function showAppContent() {
        const appContent = document.querySelector('.contents-gaia');
        if (appContent) {
            appContent.style.display = 'block';
        }
    }

    // Event triggered when the app's index page is displayed
    kintone.events.on('app.record.index.show', function(event) {
        // Hide the app content when the index page is displayed
        hideAppContent();

        // Create a button to show the app content
        const showButton = document.createElement('button');
        showButton.textContent = 'Show Content';
        showButton.onclick = showAppContent;

        // Create a button to hide the app content
        const hideButton = document.createElement('button');
        hideButton.textContent = 'Hide Content';
        hideButton.onclick = hideAppContent;

        // Append the buttons to the Kintone header menu space
        const headerMenuSpace = kintone.app.getHeaderMenuSpaceElement();
        headerMenuSpace.appendChild(showButton);
        headerMenuSpace.appendChild(hideButton);

        return event;
    });

})();
1 Like