App initialization issue in Custom ticket sidebar App

Hi Team,

We want to hide a few options in the ticket fields dropdown, so we have written the “ticket sidebar” or “ticket background” app’s core (almost all) logic code inside the “app.initialized()”, so that ticket fields will be affected as soon as the ticket is opened.

But some times, we see that ticket fields are not getting affected, and we also don’t see any logs provided inside “app.initialized()” in inspect.

Please find the code we used below.

init();

async function init() {

  app.initialized()
    .then(async function (_client) {
      client = _client;
      const installed_parameters = await client.iparams.get();

      Rules_array = installed_parameters.Rules_array
      console.log("Rules_array", Rules_array);

      dd_ticket_fields = await get_ticket_fields();
      console.log("dd_ticket_fields", dd_ticket_fields);
      create_ind_arrays();

    });
}

Do I need to make any changes in code to make sure that the app is triggered as soon as a ticket is opened?

Thanks,
Suman C.