Configure onUserCreate, onUserUpdate and onUserDelete

onUserCreate

Agents and service requesters are considered as users of the Freshservice system. The onUserCreateevent is triggered when,

  • A new agent is created in the Freshservice system.
  • A new requester is created in the Freshservice system.

Subscribe to the onUserCreate event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onUserCreate": {
      "handler": "onUserCreateCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports= {
  onUserCreateCallback: function(payload){
    console.log("Logging arguments from onUserCreate event: "+ JSON.stringify(payload);
  }
}

Attributes of the data object

  • actorobject

    Information pertaining to the entity who triggered the onUserCreate event in the Freshservice system.

  • user

    Information pertaining to a user in the Freshservice system.

onUserUpdate

The onUserUpdate event is triggered in the Freshservice system when,

  • Agent details are updated in the Freshservice system.
  • An agent or requester is deactivated or reactivated.
  • Requester details are updated in the Freshservice system.
  • Requester is converted to agent and vice versa.

Subscribe to the onUserUpdate event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onUserUpdate": {
    "handler": "onUserUpdateCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports = {
  onUserUpdateCallback: function(payload) {
    console.log("Logging arguments from onUserUpdate event: " + JSON.stringify(payload));
  }
}

Attributes of the data object

  • actorobject

    Information pertaining to the entity who triggered the onUserUpdate event in the Freshservice system.

  • changesobject

    Changes that triggered the onUserUpdate event, specified as a JSON object of the following format:

    
    "changes": {
       //For non-array attributes
       "<user.attribute that changed>": ["Old value", "New value"]
    
       //For array attributes
    
    // For adding new objects to an array attribute
    "<user.attribute that changed>":{
      "add": [<array of newly added user.attribute objects>]}
    
    // For removing existing objects from an array attribute
    "<user.attribute that changed>":{
      "remove": [<array of removed user.attribute objects>]}
    
    //For modifying existing array attribute values to new values
    "<user.attribute that changed>":{
       "added": ["New value"],
       "removed": ["Old value"]}
    
    //For adding new values to array attributes
    "<user.attribute that changed>":{
       "added": [<array of newly added user.attribute values>]}
    
    }
    

    Example

    
    "changes": {
       // for non-array attributes "can_see_all_tickets_from_associated_departments": [false,true],
    
      //For array attributes
       // For adding new objects to array attributes
    "agent_access": {
        "roles": {
          "add": [
            {
              "group_id": 3031,
              "id": 1797,
              "name": "IT Ops Agent",
              "scope": "specified_groups",
              "workspace_id": null,
              "workspace_name": null
           }]
       }},
    
      // For removing existing objects from array attributes
    "groups": {
        "remove": [
          {
            "id": 4633,
            "leader": false,
            "name": "Employee Relations Team",
            "observer": false,
            "workspace_id": 20,
            "workspace_name": "HR"
          },
    
       // For modifying existing array attribute values to new values
    "department_ids": {
            "added": [1981],
            "removed": [1982]
          },
    
      //For adding new values to array attributes
    "secondary_emails": {
            "added": [
              "Jasonsmith23@ggmail.com",
              "Jasonsmith22@ggmail.com"
            ]
          }
      }
  • user

    Information pertaining to a user in the Freshservice system.

onUserDelete

The onUserDelete event is triggered in the Freshservice system when a user is forgotten in the Freshservice system and all the user details are purged from the system.

Subscribe to the onUserDelete event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onUserDelete": {
      "handler": "onUserDeleteCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports= {
  onUserDeleteCallback: function(payload){
    console.log("Logging arguments from onUserCreate event: "+ JSON.stringify(payload);
  }
}

Attributes of the data object

  • actorobject

    Information pertaining to the entity who triggered the onUserDelete event in the Freshservice system.

  • user

    Information pertaining to a user in the Freshservice system.