Error : client.request.invokeTemplate is not a function

Hi team,

I have been trying to figure out what the problem here is but I am unable to. Would be great if someone can help here.

I am trying to make a request from the installation page but I get this error.
“Uncaught TypeError: client.request.invokeTemplate is not a function” (attached screenshot)

I am trying to invoke the request this way :

client.request.invokeTemplate("getContactFields", {})
                    .then(function(data) {
                        fields = JSON.parse(data.response).fields;
                    }, function(error) {
                        //do something
                    });

I have declared the function in requests.json in the config folder:

        "getContactFields" : {
        "schema": {
        "method": "GET",
        "host": "kkindiatest.myfreshworks.com",
        "path": "/crm/sales/api/settings/contacts/fields",
        "headers": {
            "Authorization": "Token token=<%= iparam.api_key %>",
            "Content-Type": "application/json"
          }
        }

I have declared this request in the manifest.json file as well.

"requests": {
    "getContactFields": {}
}

1 Like

Hey @Krutish_Kumar ,

Welcome to the Freshworks Developer Community! :tada:

client.request.invokeTemplate() is part of the client JS which is imported in front-end HTML files. You would have to migrate from

<script src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>

to

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

You can see the migration guide docs - App code changes section which talks about this in the third point.

This should address the error. Let us know if this helped!

3 Likes

Not the OP but this solution worked for me – Thank you!

2 Likes

Hey @Luke_Padawer,

Did you as well have trouble with client.request.invokeTemplate()?

Yes, I was getting the same error as OP but your solution was the answer for me.

1 Like

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