Issue with one of the customer's Freshdek account

Hello Team,

I am using the below format in app.js


There is an issue with this format as in customer’s account, once the custom APP is saved by changing few fields in it, it is giving an error.

The error: “app is not defined.”

The same error is not coming in other freshdesk account.

Please let me know if I am missing something.

Akhil S K

I think you need to wrap the code inside the document-ready method, once all the scripts are loaded (freshclient) and then you need to execute your code.


Hello Santhosh,

After “fdk create”, we will get the below file structure.

If we use the document-ready method, the error will be “$ not defined”.

you can use like this

 document.onreadystatechange = () => {
      if (document.readyState === 'complete') {
        // your code

Hope it helps

@Akhil_Kulkarni Same as @Santhosh said, you can call the global app object after DOM is ready. Here is an example: entity-storage-samples/employee.js at main · freshworks-developers/entity-storage-samples · GitHub.

@Akhil_Kulkarni The value of app becomes available to the app using

    <script async src=""></script>

in the associated HTML file.

You must ensure that your app.js starts to execute after fresh_client.js first executes

    <script async src=""></script>
    <link rel="stylesheet" type="text/css" href="styles/style.css" />

    <div class="main">
      <p>Utilize this template code to build your App</p>
      <p id="apptext"></p>

  <script defer src="scripts/app.js"></script>
  <script async type="module" src=""></script>
  <script async nomodule src=""></script>

You can ensure it by understanding the difference: Scripts: async, defer

Usually, if you do not solve the order of scripts loading using async or defer, then next option is to fall back to enclosing document loading apis such as document.onreadystatechange or document.readyState etc.,

1 Like

Hello @Santhosh

I have tried the solution you have provided and is giving the below error.

Please can we get on a quick call once.

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