Node.js SugarCRM: SugarCRM Favorite a Record

Back to Index

Favorites specific record using the /{module}/{record_id}/favorite endpoint.
Note: This example uses our own demo SugarCRM domain containing demo data. You should replace "cscspanset.demo.sugarcrm.eu" with your own domain.

Documentation: http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.8/Integration/Web_Services/v10/Examples/Bash/How_to_Favorite_a_Record/


var os = require('os');
if (os.platform() == 'win32') {  
    var chilkat = require('chilkat_node6_win32'); 
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('chilkat_node6_arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('chilkat_node6_linux32');
    } else {
        var chilkat = require('chilkat_node6_linux64');
    }
} else if (os.platform() == 'darwin') {
    var chilkat = require('chilkat_node6_macosx');
}

function chilkatExample() {

    var rest = new chilkat.Rest();
    var success;

    success = rest.Connect("cscspanset.demo.sugarcrm.eu",443,true,true);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    rest.AddHeader("Cache-Control","no-cache");
    rest.AddHeader("OAuth-Token","OAUTH2_ACCESS_TOKEN");

    var sbReq = new chilkat.StringBuilder();

    var sbJson = new chilkat.StringBuilder();
    success = rest.FullRequestSb("PUT","/rest/v10/Accounts/0fc396b8-acd5-11e6-8a91-0681183120c1/favorite",sbReq,sbJson);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    if (rest.ResponseStatusCode !== 200) {
        console.log("Received error response code: " + rest.ResponseStatusCode);
        console.log("Response body:");
        console.log(sbJson.GetAsString());
        return;
    }

    console.log("Example Completed.");

}

chilkatExample();

Sample JSON Response Body

{
  "id": "0fc396b8-acd5-11e6-8a91-0681183120c1",
  "name": "Deltzmeier Software Systems",
  "date_entered": "2016-11-17T14:49:00+00:00",
  "date_modified": "2016-12-14T00:13:47+00:00",
  "modified_user_id": "1",
  "modified_by_name": "admin Administrator",
  "modified_user_link": {
    "full_name": "admin Administrator",
    "id": "1",
    "_acl": {
      "fields": {
        "user_name": {
          "write": "no",
          "create": "no"
        },
        "user_hash": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "system_generated_password": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "pwd_last_changed": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "authenticate_id": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "sugar_login": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "is_admin": {
          "write": "no",
          "create": "no"
        },
        "external_auth_only": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "last_login": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "title": {
          "write": "no",
          "create": "no"
        },
        "department": {
          "write": "no",
          "create": "no"
        },
        "status": {
          "write": "no",
          "create": "no"
        },
        "portal_only": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "show_on_employees": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "employee_status": {
          "write": "no",
          "create": "no"
        },
        "reports_to_id": {
          "write": "no",
          "create": "no"
        },
        "reports_to_name": {
          "write": "no",
          "create": "no"
        },
        "reports_to_link": {
          "write": "no",
          "create": "no"
        },
        "is_group": {
          "read": "no",
          "write": "no",
          "create": "no"
        }
      },
      "admin": "no",
      "developer": "no",
      "edit": "no",
      "delete": "no",
      "import": "no",
      "export": "no",
      "massupdate": "no",
      "create": "no",
      "_hash": "6609e3b6881aab5349af8271ff796164"
    }
  },
  "created_by": "1",
  "created_by_name": "admin Administrator",
  "created_by_link": {
    "full_name": "admin Administrator",
    "id": "1",
    "_acl": {
      "fields": {
        "user_name": {
          "write": "no",
          "create": "no"
        },
        "user_hash": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "system_generated_password": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "pwd_last_changed": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "authenticate_id": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "sugar_login": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "is_admin": {
          "write": "no",
          "create": "no"
        },
        "external_auth_only": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "last_login": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "title": {
          "write": "no",
          "create": "no"
        },
        "department": {
          "write": "no",
          "create": "no"
        },
        "status": {
          "write": "no",
          "create": "no"
        },
        "portal_only": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "show_on_employees": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "employee_status": {
          "write": "no",
          "create": "no"
        },
        "reports_to_id": {
          "write": "no",
          "create": "no"
        },
        "reports_to_name": {
          "write": "no",
          "create": "no"
        },
        "reports_to_link": {
          "write": "no",
          "create": "no"
        },
        "is_group": {
          "read": "no",
          "write": "no",
          "create": "no"
        }
      },
      "admin": "no",
      "developer": "no",
      "edit": "no",
      "delete": "no",
      "import": "no",
      "export": "no",
      "massupdate": "no",
      "create": "no",
      "_hash": "6609e3b6881aab5349af8271ff796164"
    }
  },
  "description": "Dieser potentielle Kunde wurde uns von der ABC Bank empfohlen (Sandra Hachinger).",
  "deleted": false,
  "facebook": "",
  "twitter": "deltzmeier",
  "googleplus": "",
  "account_type": "Customer",
  "industry": "Hospitality",
  "annual_revenue": "\u003E 10.000.000.000\u20ac",
  "phone_fax": "+49 77 035 55 52 34",
  "billing_address_street": "Maximilianstrasse 224",
  "billing_address_street_2": "",
  "billing_address_street_3": "",
  "billing_address_street_4": "",
  "billing_address_city": "M\u00fcnchen",
  "billing_address_state": "Bayern",
  "billing_address_postalcode": "80539",
  "billing_address_country": "Deutschland",
  "rating": "7",
  "phone_office": "+49 93 884 28 72 21",
  "phone_alternate": "+49 46 387 26 60 60",
  "website": "http:\/\/www.deltzmeiersoftwaresystems.de",
  "ownership": "Trautheim Bank",
  "employees": "\u003E10,000",
  "ticker_symbol": "FWB",
  "shipping_address_street": "Maximilianstrasse 224",
  "shipping_address_street_2": "",
  "shipping_address_street_3": "",
  "shipping_address_street_4": "",
  "shipping_address_city": "M\u00fcnchen",
  "shipping_address_state": "Bayern",
  "shipping_address_postalcode": "80539",
  "shipping_address_country": "Deutschland",
  "parent_id": "",
  "sic_code": "77621",
  "duns_num": "4589658",
  "parent_name": "",
  "member_of": {
    "name": "",
    "id": "",
    "_acl": {
      "fields": [
      ],
      "admin": "no",
      "developer": "no",
      "_hash": "20f20362961956e200539170d3fdabb9"
    }
  },
  "campaign_id": "",
  "campaign_name": "",
  "campaign_accounts": {
    "name": "",
    "id": "",
    "_acl": {
      "fields": [
      ],
      "admin": "no",
      "developer": "no",
      "_hash": "20f20362961956e200539170d3fdabb9"
    }
  },
  "following": true,
  "my_favorite": true,
  "tag": [
  ],
  "locked_fields": [
  ],
  "assigned_user_id": "seed_sarah_id",
  "assigned_user_name": "Sarah Smith",
  "assigned_user_link": {
    "full_name": "Sarah Smith",
    "id": "seed_sarah_id",
    "_acl": {
      "fields": {
        "user_name": {
          "write": "no",
          "create": "no"
        },
        "user_hash": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "system_generated_password": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "pwd_last_changed": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "authenticate_id": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "sugar_login": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "is_admin": {
          "write": "no",
          "create": "no"
        },
        "external_auth_only": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "last_login": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "title": {
          "write": "no",
          "create": "no"
        },
        "department": {
          "write": "no",
          "create": "no"
        },
        "status": {
          "write": "no",
          "create": "no"
        },
        "portal_only": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "show_on_employees": {
          "read": "no",
          "write": "no",
          "create": "no"
        },
        "employee_status": {
          "write": "no",
          "create": "no"
        },
        "reports_to_id": {
          "write": "no",
          "create": "no"
        },
        "reports_to_name": {
          "write": "no",
          "create": "no"
        },
        "reports_to_link": {
          "write": "no",
          "create": "no"
        },
        "is_group": {
          "read": "no",
          "write": "no",
          "create": "no"
        }
      },
      "admin": "no",
      "developer": "no",
      "edit": "no",
      "delete": "no",
      "import": "no",
      "export": "no",
      "massupdate": "no",
      "create": "no",
      "_hash": "6609e3b6881aab5349af8271ff796164"
    }
  },
  "team_count": "",
  "team_count_link": {
    "team_count": "",
    "id": "1",
    "_acl": {
      "fields": {
        "id": {
          "write": "no",
          "create": "no"
        },
        "name": {
          "write": "no",
          "create": "no"
        },
        "date_entered": {
          "write": "no",
          "create": "no"
        },
        "date_modified": {
          "write": "no",
          "create": "no"
        },
        "modified_user_id": {
          "write": "no",
          "create": "no"
        },
        "modified_by_name": {
          "write": "no",
          "create": "no"
        },
        "created_by": {
          "write": "no",
          "create": "no"
        },
        "created_by_name": {
          "write": "no",
          "create": "no"
        },
        "description": {
          "write": "no",
          "create": "no"
        },
        "deleted": {
          "write": "no",
          "create": "no"
        },
        "created_by_link": {
          "write": "no",
          "create": "no"
        },
        "modified_user_link": {
          "write": "no",
          "create": "no"
        },
        "activities": {
          "write": "no",
          "create": "no"
        },
        "name_2": {
          "write": "no",
          "create": "no"
        },
        "associated_user_id": {
          "write": "no",
          "create": "no"
        },
        "private": {
          "write": "no",
          "create": "no"
        },
        "users": {
          "write": "no",
          "create": "no"
        },
        "teams_sets": {
          "write": "no",
          "create": "no"
        },
        "activities_teams": {
          "write": "no",
          "create": "no"
        },
        "following": {
          "write": "no",
          "create": "no"
        },
        "following_link": {
          "write": "no",
          "create": "no"
        },
        "my_favorite": {
          "write": "no",
          "create": "no"
        },
        "favorite_link": {
          "write": "no",
          "create": "no"
        },
        "locked_fields": {
          "write": "no",
          "create": "no"
        },
        "locked_fields_link": {
          "write": "no",
          "create": "no"
        }
      },
      "admin": "no",
      "developer": "no",
      "edit": "no",
      "delete": "no",
      "import": "no",
      "massupdate": "no",
      "create": "no",
      "_hash": "8b45033179dfb79bf13ef2e0f5948464"
    }
  },
  "team_name": [
    {
      "id": "1",
      "name": "Global",
      "name_2": "",
      "primary": true,
      "selected": false
    },
    {
      "id": "West",
      "name": "West",
      "name_2": "",
      "primary": false,
      "selected": false
    }
  ],
  "email": [
    {
      "email_address": "contact@deltzmeiersoftwaresystems.de",
      "invalid_email": false,
      "opt_out": false,
      "primary_address": true,
      "reply_to_address": false
    }
  ],
  "email1": "contact@deltzmeiersoftwaresystems.de",
  "email2": "",
  "invalid_email": false,
  "email_opt_out": false,
  "email_addresses_non_primary": "",
  "ob_12_c": false,
  "ob_13_c": false,
  "ob_21_c": false,
  "ob_21_meeting_c": false,
  "ob_case_c": false,
  "ob_case_closed_c": false,
  "status_c": "11",
  "accountnr_c": "1003902DU",
  "status2_c": "3",
  "delivery_block_c": "2",
  "customer_block_c": "2",
  "accounts_accounts_1_name": "",
  "accounts_accounts_1_right": {
    "name": "",
    "id": "",
    "_acl": {
      "fields": [
      ],
      "admin": "no",
      "developer": "no",
      "_hash": "20f20362961956e200539170d3fdabb9"
    }
  },
  "accounts_accounts_1accounts_ida": "",
  "dropdown_territory_c": "",
  "linked_in_url_c": "",
  "dri_workflow_template_id": "",
  "dri_workflow_template_name": "",
  "dri_workflow_template_link": {
    "name": "",
    "id": "",
    "_acl": {
      "fields": {
        "id": {
          "write": "no",
          "create": "no"
        },
        "name": {
          "write": "no",
          "create": "no"
        },
        "date_entered": {
          "write": "no",
          "create": "no"
        },
        "date_modified": {
          "write": "no",
          "create": "no"
        },
        "modified_user_id": {
          "write": "no",
          "create": "no"
        },
        "modified_by_name": {
          "write": "no",
          "create": "no"
        },
        "created_by": {
          "write": "no",
          "create": "no"
        },
        "created_by_name": {
          "write": "no",
          "create": "no"
        },
        "description": {
          "write": "no",
          "create": "no"
        },
        "deleted": {
          "write": "no",
          "create": "no"
        },
        "created_by_link": {
          "write": "no",
          "create": "no"
        },
        "modified_user_link": {
          "write": "no",
          "create": "no"
        },
        "activities": {
          "write": "no",
          "create": "no"
        },
        "following": {
          "write": "no",
          "create": "no"
        },
        "following_link": {
          "write": "no",
          "create": "no"
        },
        "my_favorite": {
          "write": "no",
          "create": "no"
        },
        "favorite_link": {
          "write": "no",
          "create": "no"
        },
        "tag": {
          "write": "no",
          "create": "no"
        },
        "tag_link": {
          "write": "no",
          "create": "no"
        },
        "locked_fields": {
          "write": "no",
          "create": "no"
        },
        "locked_fields_link": {
          "write": "no",
          "create": "no"
        },
        "team_id": {
          "write": "no",
          "create": "no"
        },
        "team_set_id": {
          "write": "no",
          "create": "no"
        },
        "acl_team_set_id": {
          "write": "no",
          "create": "no"
        },
        "team_count": {
          "write": "no",
          "create": "no"
        },
        "team_name": {
          "write": "no",
          "create": "no"
        },
        "acl_team_names": {
          "write": "no",
          "create": "no"
        },
        "team_link": {
          "write": "no",
          "create": "no"
        },
        "team_count_link": {
          "write": "no",
          "create": "no"
        },
        "teams": {
          "write": "no",
          "create": "no"
        },
        "available_modules": {
          "write": "no",
          "create": "no"
        },
        "dri_workflows": {
          "write": "no",
          "create": "no"
        },
        "dri_subworkflow_templates": {
          "write": "no",
          "create": "no"
        },
        "copies": {
          "write": "no",
          "create": "no"
        },
        "points": {
          "write": "no",
          "create": "no"
        },
        "related_activities": {
          "write": "no",
          "create": "no"
        },
        "active": {
          "write": "no",
          "create": "no"
        },
        "assignee_rule": {
          "write": "no",
          "create": "no"
        },
        "target_assignee": {
          "write": "no",
          "create": "no"
        },
        "copied_template_id": {
          "write": "no",
          "create": "no"
        },
        "copied_template_name": {
          "write": "no",
          "create": "no"
        },
        "copied_template_link": {
          "write": "no",
          "create": "no"
        }
      },
      "admin": "no",
      "developer": "no",
      "edit": "no",
      "delete": "no",
      "import": "no",
      "export": "no",
      "massupdate": "no",
      "create": "no",
      "_hash": "bcf51009c6c933514db39a6f8ba5b10d"
    }
  },
  "latitude_c": "48.1384652",
  "longitude_c": "11.5832802",
  "_acl": {
    "fields": {}
  },
  "_module": "Accounts"
}