Invoke template in app.js

Hi Team,

We have facing a error is app.js code. how should we invoke the template for the app.js.

i have shared the code below for your reference.

  return new Promise(function (resolve, reject) {
    if (method == "GET") {
      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>" };
      var options = { headers: headers, body: body };
      return fssClient.request.get(url, options).then(
        function (data) {
          resolve(data.response);
        },
        function (error) {

          reject(error);
        }
      )
    } else if (method == "POST") {

      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>", "Content-Type": "application/json" };
      var options = { headers: headers, body: body };
      return fssClient.request.post(url, options).then(
        function (data) {

          resolve(data.response);
        },
        function (error) {

          reject(error);
        }
      )
    } else if (method == "POST-RECORDING") {
      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>", "Content-Type": "multipart/form-data" };
      var options = { headers: headers, body: body };
      return fssClient.request.post(url, options).then(
        function (data) {

          resolve(data.response);
        },
        function (error) {

          reject(error);
        }
      )
    } else if (method == "PUT") {
      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>", "Content-Type": "application/json" };
      var options = { headers: headers, body: body };
      return fssClient.request.put(url, options).then(
        function (data) {

          resolve(data.response);
          showNotify("Data Resolved","success")
        },
        function (error) {

          reject(error);
          showNotify("Data Rejected Notification","warning")

        }
      )
    } else {
      showNotify("Something went wrong with the communication to Freshsales Suite.", "warning");
    }
  });
}```

The code is in App.js file

Hi @bala

Please refer to the below link to get more insights.

https://developers.freshworks.com/docs/app-sdk/v2.3/freshsales-suite/advanced-interfaces/request-method/

Hope that helps, let me know otherwise :wink: .

Thank you.

Hi Team,

We successfully migrated the code and, despite receiving warnings, we were still able to access localhost:3000. However, since yesterday, we are unable to access localhost:3000 and continue to receive only warnings.

I have attached screenshot of the warnings:


This is my request.json

  "saveRecordingLkToSalesActivity":{
      "schema": {
          "protocol": "https",
          "method": "POST",
          "host":"<%= context.domain %>",
          "path": "/crm/sales/api/sales_activities",
          "headers": {
            "Authorization":"Token token=<%= iparam.apiKey %>",
            "Content-Type": "application/json"
          }
        }
  },
  "saveRecordingLkToFileSection":{
      "schema": {
          "protocol": "https",
          "method": "POST",
          "host":"<%= context.domain %>",
          "path": "/crm/sales/api/document_links",  
          "headers": {
            "Authorization":"Token token=<%= iparam.apiKey %>",
            "Content-Type": "application/json"
          }
        }
  },
  "getListOfFiles":{
      "schema": {
          "protocol": "https",
          "method": "GET",
          "host":"<%= context.domain %>",
          "path": "/crm/sales/api/deals/<%= context.id %>/document_associations",
          "headers": {
            "Authorization":"Token token=<%= iparam.apiKey %>",
            "Content-Type": "application/json"
          }
        }
  },
  "getDealDetailsForTheTask":{
      "schema": {
          "protocol": "https",
          "method": "GET",
          "host":"<%= context.domain %>",
          "path": "/crm/sales/api/deals/<%= context.dealId %>",
          "headers": {
            "Authorization":"Token token=<%= iparam.apiKey %>",
            "Content-Type": "application/json"
          },
          "query":{
            "include":"contacts"
        }
  }
},
  "searchContacts":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/search",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      },
      "query":{
        "q": "<%= context.searchValue %>",
        "include": "contact",
        "per_page":"25"
      }
    }


  },
  "createCallLog":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/sales_activities",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "createContact":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/sales_activities",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "saveSalesActivity":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/sales_activities",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "saveCallRecordingLink":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/notes",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "getDispositionTypes":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"assupol-staging.myfreshworks.com",
      "path": "/crm/sales/api/selector/sales_activity_types",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "getDispositionCodes":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"assupol-staging.myfreshworks.com",
      "path": "/crm/sales/api/settings/sales_activities/fields",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "getDealStages":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/selector/deal_stages",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "getSalesActivityTypes":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/selector/sales_activity_types",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "getSalesActivityEntityTypes":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/selector/sales_activitie_entity_types",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "updateDealStageId":{
    "schema": {
      "protocol": "https",
      "method": "PUT",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/deals/<%= context.dealId %>",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "updateDealRecRefField":{
    "schema": {
      "protocol": "https",
      "method": "PUT",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/deals/<%= context.dealId %>",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }
  },
  "updateDealRecReferenceIds":{
    "schema": {
      "protocol": "https",
      "method": "PUT",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/deals/<%= context.dealId %>",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "getCallSpecificDealDetails":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/deals/<%= context.dealId %>",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "addRecordingLinkToFileSection":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/document_links",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "updateAlternateNumberForDeal":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/deals/<%= context.dealId %>",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "createTaskForAlternateNumber":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/tasks",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }
    

  },
  "createTaskOnPageRefresh":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/tasks",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  },
  "listAllTaskOwnerFilterOverdue":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/tasks",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      },
      "query":{
        "filter":"overdue",
        "include":"targetable"
      }
    }
  },
  "listAllTaskOwnerFilterToday":{
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/tasks",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      },
      "query":{
        "filter":"due_today",
        "include":"targetable"
      }
    }

  },
  "createTaskDueToCallDisconnect":{
    "schema": {
      "protocol": "https",
      "method": "POST",
      "host":"<%= context.domain %>",
      "path": "/crm/sales/api/tasks",
      "headers": {
        "Authorization":"Token token=<%= iparam.apiKey %>",
        "Content-Type": "application/json"
      }
    }

  }
} ```

This is my Manifest.json

``` {
  "platform-version": "2.3",
  "product": {
    "freshworks_crm": {
      "location": {
        "left_nav_cti": {
          "url": "index.html",
          "icon": "styles/images/icon.svg"
        },
        "deal_entity_menu":{
           "url": "index.html",
          "icon": "styles/images/icon.svg"
        }
      },
      "events": {
        "onDealCreate": {
          "handler": "onDealCreateCallback"
        },
        "onDealUpdate": {
          "handler": "onDealCreateCallback"
        },
        "onTaskCreate": {
          "handler": "onTaskCreateHandler"
        },
        "onTaskUpdate": {
          "handler": "onTaskUpdateHandler"
        }
      },
      "requests": {
        "saveRecordingLkToSalesActivity":{},
        "saveRecordingLkToFileSection":{},
        "getListOfFiles":{},
        "getDealDetailsForTheTask":{},
        "searchContacts":{},
        "createCallLog":{},
        "createContact":{},
        "saveSalesActivity":{},
        "saveCallRecordingLink":{},
        "getDispositionTypes":{},
        "getDispositionCodes":{},
        "getDealStages":{},
        "getSalesActivityTypes":{},
        "getSalesActivityEntityTypes":{},
        "updateDealStageId":{},
        "updateDealRecRefField":{},
        "updateDealRecReferenceIds":{},
        "getCallSpecificDealDetails":{},
        "addRecordingLinkToFileSection":{},
        "updateAlternateNumberForDeal":{},
        "createTaskForAlternateNumber":{},
        "createTaskOnPageRefresh":{},
        "listAllTaskOwnerFilterOverdue":{},
        "listAllTaskOwnerFilterToday":{}
      },
      "functions": {
        "getAllOverdueTasks": {
          "timeout": 10
        },
        "getDealDetailsForTheTask": {
          "timeout": 10
        },
        "saveRecordingLkToSalesActivity": {
          "timeout": 10
        },
        "saveRecordingLkToFileSection":{
          "timeout": 10
        },
        "getListOfFiles":{
          "timeout": 10
        },
        "getDispositionTypes":{
          "timeout": 10
        },
        "onGetDispositionCodes":{
          "timeout": 10
        }
       
      }
    }
  },
  "dependencies": {
    "luxon": "1.26.0",
    "moment-business-time": "1.1.1"
  },
  "engines": {
    "node": "18.19.1",
    "fdk": "9.1.1"
  }
}

Please let me know if i missed something

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