Interface Methods

You can use the interface methods to enable an app to trigger certain actions on the Freshsales user interface.

Global Interface Methods

The following methods can be used in all locations:

Show Modal

The method opens a modal dialog box in an IFrame to display HTML content to users. Events methods and interface methods are not supported within the Modal IFrame.

Notes:
1. In the following code, the template field is mandatory. If no value is specified, an error message is displayed when the method is run.
2. The title field is optional and supports 35 characters; beyond that the title is truncated. The default title is Sample Modal.


template.html

Copied Copy
1
2
3
4
5
6
7
8
client.interface.trigger("showModal", { title: "Sample Modal", template: "modal.html" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

To send data from template.html to the modal dialog box, add the data parameter as shown in the following code.

Copied Copy
1
2
3
4
5
6
7
8
9
client.interface.trigger("showModal", { title: "Sample Modal", template: "modal.html", data: {name: "James", email: "James@freshworks.com"} }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

To retrieve the data within the modal dialog box, in the modal.html file, use the context method as shown in the following code.

Copied Copy
1
2
3
4
5
6
client.instance.context().then(function(context){ console.log(context) /* Output: { instanceId: "modalinstanceID", location: "location", parentId: "parentinstanceID", data: {name: "James", email: "James@freshworks.com"} } */ }.catch(function(error) { // error - error object }));

If the modal dialog box includes Data Methods and Request Methods, include the following fresh_client link.

modal.html

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

Show Confirm

The method displays a confirmation dialog box, to users, with a title, a message, and the save and cancel buttons. By default, the dialog box displays the Save and Cancel buttons and you can use saveLabel and cancelLabel to modify the button labels.
Timeout for the confirmation dialog box is 10 seconds.

Notes:
1. In the following code, the message field is mandatory and supports a maximum of 100 characters; beyond that the message is truncated.
2. The title field is optional and supports a maximum of 30 characters; beyond that the title is truncated.
3. The saveLabel and cancelLabel fields support a maximum of 11 characters.


Sample confirmation dialog with saveLabel and cancelLabel

Copied Copy
1
2
3
4
5
6
7
8
9
10
11
client.interface.trigger("showConfirm", { title: "Sample Confirm", message: "Do you want to save the changes?", saveLabel: "save", cancelLabel: "ignore" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object }); /*"title" and "message" should be plain text.*/
EXPAND ↓

Show Notification

The method displays an alert notification on the user interface.

Notes:
1. In the following code, the message field supports a maximum of 100 characters; beyond that the message is truncated.
2. The type field is mandatory and the supported values are: success, info, warning, and danger.


Sample notification with message

Copied Copy
1
2
3
4
5
6
7
8
9
client.interface.trigger("showNotify", { type: "success", message: "sample notification" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object }); /*"title" and "message" should be plain text.*/

Open Add Contact

The method opens the ADD CONTACT window.

Copied Copy
1
2
3
4
5
6
7
client.interface.trigger("open", { id: "contact" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

Open Add Account

The method opens the ADD ACCOUNT window.

Copied Copy
1
2
3
4
5
6
7
client.interface.trigger("open", { id: "account" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

Open Add Deal

The method opens the ADD DEAL window.

Copied Copy
1
2
3
4
5
6
7
client.interface.trigger("open", { id: "deal" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

Open Call Log

The method opens the CALL LOG window.

Copied Copy
1
2
3
4
5
6
id: "calllog" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

Show Contact

This method allows users to navigate to the Contact Details page.

Copied Copy
1
2
3
4
5
6
7
client.interface.trigger("show", { id: "contact",value:"1" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

Show Account

This method allows users to navigate to the Account Details page.

Copied Copy
1
2
3
4
5
6
7
client.interface.trigger("show", { id: "account",value:"1" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });

Show Deal

This method allows users to navigate to the Deal Details page.

Copied Copy
1
2
3
4
5
6
7
client.interface.trigger("show", { id: "deal",value:"1" }).then(function(data) { // data - success message }).catch(function(error) { // error - error object });