Client.events is not defined

I am migrating an application to 2.3. I am having problems with the client object in that some of its methods appear to be missing when using running a custom configuration page

client.events
client.request.invokeTemplate

Here is the code I am using to run on the

        document.onreadystatechange = function () {
          if (document.readyState === 'interactive')
            renderApp();
          async function renderApp() {
            try {
              var client=await app.initialized();
              client.events.on("app.activated",renderScreen);

Hello @DaveWP ,
Can you please share what error you are facing in the browser console. Also I hope you have changed the script tag for freshclient
Eg

  <script defer src="{{{appclient}}}"></script>

You can also refer this thread for Reference

Hope it helps.

Thanks for the feedback. I’ve realised that I did not include the defer statement in the loader.

When I do include the defer statement, I now find that I get an error on calling app.initialised as the library was still being loaded. If I change the code to check that document.readyState is ‘complete’. I get the same error

The defer statement is being translated to following when viewed in the debugger.

<script defer src="https://cdn.freshdev.io/assets/app-client@2.js"></script>

I’ve attached a copy of a screenshot showing the contents of client immediately after the return from the app.initialized function

Here is the call trace for the error

TypeError: client.events is undefined
    renderApp http://localhost:10001/custom_configs/form:137
    onreadystatechange http://localhost:10001/custom_configs/form:149
    EventHandlerNonNull* http://localhost:10001/custom_configs/form:133
type or paste code here

Note that I’ve used Firefox as this allows me to see the actual code. When I attempt to the development mode window in Bing and Chrome, I get a blank window when attempting to see the javascript code.

Resolved - clients.events is not available in custom iparams.html

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.