Selecting a specific attribute on a returned data using Data Method

I am running the following data method to get the company details of a given ticket."company").then (
    function(data) {
     CompanyData1 = JSON.stringify(data);
    function(error) {
      // failure operation

Basically, this returns all the company details of the ticket. The retrieved payload can be seen as below:

Sample Data
  "company": {
    "avatar": [{
      "attachment_url": "<AVATAR_URL>",
      "content_type": "application/octet-stream",
      "created_at": "2015-08-28T10:27:58Z",
      "id": 9,
      "name": "lantern.png",
                  admin_status: XXXX
                  business_type: "XXXX"
                  corporate: "XXXX"
                  hs_company_id: "XXXX"
                  lifecycle_stage: "XXXX"
                 oabp_clinic_id: "XXXX"
                 pims_platform: "XXXX"
                  region: XXXX,
      "thumb_url": "<THUMB_URL>",

I want to retrieve a specific attribute once I retrieve the data. Is this feasible?

can you please explain a bit clearer?
are you trying to retrieve a value from the value which you received? if so yes, you can traverse through the object.



Hi @Santhosh -

That is correct. I am trying to compare an attribute with a value. Basically, with the given Sample data the above, I want to execute the following:

if (data.business_type = "XXXXX")

However, I tried to run a console.log( inside my function to test this out but it said ‘undefined’.

Hey @Chathuranga_Suriyaar

do you want to retrieve the company id or the avatar id (as in your snippet, only the latter is shown).

If your goal is the company id (which is not shown in your snippet), it actually should work with:


Thank you so much! This works!!

1 Like

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