Use data method

Data method is an interface that the developer platform provides to enable your app to retrieve product data (in the form of JSON payloads).

When an app is initialized successfully, the parent app (Freshworks product) passes a client reference to your app. Your app can use this reference and the developer platform’s data method to retrieve the different objects on the Freshworks product UI, as payloads.

To enable your app to retrieve product data, in the app.js file,

  1. Subscribe to the app.initialized event, through an event listener. When the app is initialized, the parent application passes a client reference to the app.
  2. After app initialization, use the data method - client.data.get(<objectName>) - to retrieve the specified object (<objectName>) from the product UI.

As part of the app logic, your app can process the retrieved payload to derive meaningful results.

This section,

  • Lists all the objects that can be retrieved by using the data method.
  • Describes all the attributes of the retrieved object.

Data objects accessible from all pages

These objects are available in all pages of the product UI. Irrespective of the page on which the app is deployed, when you use the data method -client.data.get(<objectName>)- and retrieve these objects, the corresponding payload is retrieved.

An app can retrieve the following objects irrespective of where the app is deployed:

currentHost

A global app, with module-specific app logic, can be deployed on various Freshworks products. currentHost refers to the Freshworks product on which the app is currently running. Based on the currentHost, from the back-end, we retrieve the modules that the app user working on the currentHost has subscribed to. Based on the subscribed modules, we can retrieve the product-specific urls that the app built for the modules can use, to access the product resources.

For more information on currentHost, see Global app concepts.

Use the sample code shown on the right pane > Sample code tab, to retrieve the currentHost object that contains information on,

  • All modules that the app user using the currentHost has access to and applicable to the app.
  • All product names and the corresponding account urls through which the app built for the subscribed modules can access product resources.

Attributes of the currentHost object

  • subscribed_modulesarray of strings

    All modules that the app user has subscribed to and present in the app manifest.

  • endpoint_urlsobject

    Product name and account url (domain name) to access product resources, specified as a key (product name) - value (account URL) pair.

    You can use the domain name to construct api calls that can access product resources.

loggedInUser

Use the sample code shown on the right pane > Sample code tab, to retrieve information on the agent logged into the Freshservice.

Attributes of the loggedInUser object

  • availableboolean

    If the agent is in a group that has enabled Automatic Ticket Assignment, this attribute will be set to 'true' if the agent is accepting new tickets.

  • created_atstring

    Contact creation timestamp.

  • group_idsarray of strings

    Group IDs associated with the agent.

  • idinteger

    User ID of the agent.

  • occasionalboolean

    Specifies whether the agent is an occasional agent or a full-time agent .

    Possible values: true, false

  • signaturestring

    Signature of the agent in HTML format.

  • updated_atstring

    Agent updated timestamp.

Change details page

An app deployed on the Change details page can use the client.data.get(<objectName>) data method and retrieve the following objects:

change

Use the sample code shown on the right pane > Sample code tab, to retrieve information of the change.

Attributes of the change object

  • attachmentsarray of objects

    Change attachments.

  • cc_emailobject of arrays

    Email address added in the 'cc' field of the change.

  • change_typestring

    This field categorizes the change according to the different kinds of issues your support team deals with.

  • created_atstring

    Change creation timestamp.

  • custom_fieldobject

    Key value pairs containing the names and values of custom fields.

  • department_idinteger

    ID of the department to which this change belongs.

  • descriptionstring

    Content of the change in plain text.

  • email_config_idinteger

    ID of email config which is used for this change.

  • group_idinteger

    ID of the group to which the change has been assigned.

  • idinteger

    ID of the change.

  • owner_idinteger

    ID of the agent to whom the change has been assigned.

  • priorityinteger

    Change priority value.

    Possible values:

    1: Low priority

    2: Medium priority

    3: High priority

    4: Urgent

  • priority_namestring

    Change priority text.

  • requester_idinteger

    User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.

  • statusinteger

    Change status value.

    Possible values:

    1: Open

    2: Planning

    3: Awaiting Approval

    4: Pending Release

    5: Pending Review

    6: Closed

  • status_namestring

    Change status text.

  • subjectstring

    Subject of the change.

  • updated_atstring

    Change updated timestamp.

requester

Use the sample code shown on the right pane > Sample code tab, to retrieve information of a requester.

Attributes of the requester object

  • activeboolean

    Set to 'true' if the user has been verified.

  • addressstring

    Address of the user.

  • created_atstring

    User creation timestamp.

  • custom_fieldobject

    Key value pairs containing the names and values of the custom fields.

  • deletedboolean

    Set to 'true' if the user has been deleted.

  • descriptionstring

    A short description of the user.

  • emailstring

    Primary email address of the user. If you want to associate additional email(s) with this user, use the other_emails attribute.

  • external_idinteger

    ID of the user in an external system.

  • helpdesk_agentboolean

    Set to 'true' if the user is an agent.

  • idinteger

    ID of the user.

  • job_titlestring

    Job title of the user.

  • languagestring

    Language of the user.

  • mobileinteger

    Mobile number of the user.

  • namestring

    Name of the user.

  • phoneinteger

    Telephone number of the user.

  • time_zonestring

    Time zone in which the user resides.

  • updated_atstring

    User updated timestamp.

agent

Use the sample code shown on the right pane > Sample code tab, to retrieve information of an agent.

Attributes of the agent object

  • activeboolean

    Set to 'true' if the user has been verified.

  • addressstring

    Address of the user.

  • created_atstring

    User creation timestamp.

  • deletedboolean

    Set to 'true' if the user has been deleted.

  • descriptionstring

    A short description of the user.

  • emailstring

    Primary email address of the user.

    If you want to associate additional email(s) with this user, use the other_emails attribute.

  • external_idinteger

    ID of the user in an external system.

  • helpdesk_agentboolean

    Set to 'true' if the user is an agent.

  • idinteger

    ID of the user.

  • job_titlestring

    Job title of the user.

  • languagestring

    Language of the user.

  • mobileinteger

    Mobile number of the user.

  • namestring

    Name of the user.

  • phoneinteger

    Telephone number of the user.

  • time_zonestring

    Time zone in which the user resides.

  • updated_atstring

    User updated timestamp.

group

Use the sample code shown on the right pane > Sample code tab, to retrieve information of the group.

Attributes of the group object

  • agent_idsarray of integers

    Array of agent IDs separated by commas.

  • idinteger

    ID of the group.

  • namestring

    Name of the group.

backoutPlan

Use the sample code shown on the right pane > Sample code tab, to retrieve description of the backout plan.

Attributes of the backoutPlan object

  • backoutPlanstring

    Description of the backout plan.

changeImpact

Use the sample code shown on the right pane > Sample code tab, to retrieve description of the change impact.

Attributes of the changeImpact object

  • changeImpactstring

    Description of the change impact.

changePlan

Use the sample code shown on the right pane > Sample code tab, to retrieve description of the change plan.

Attributes of the changePlan object

  • changePlanstring

    Description of the change plan.

changeReason

Use the sample code shown on the right pane > Sample code tab, to retrieve description of the change reason.

Attributes of the changeReason object

  • changeReasonstring

    Description of the change reason.