⚙ Operations Hub

KristeenRomero
Participant | Platinum Partner
Participant | Platinum Partner

Custom Code for Custom Object Search

I'm trying to add some custom code into a workflow to search through the properties of a Patient Records custom object I created, but it keeps giving me this error:

TypeError: Cannot read property 'searchApi' of undefined


It looks like I can't use the search API the same way I do when I'm searching through contacts or deals. What do I need to fix here? (And just to preface this, I'm not a developer, just learning JS as I go)

 

hubspotClient.crm.patient_records.searchApi.doSearch(publicObjectSearchRequest).then(searchResponse =>{
      hubspotClient.crm.contacts.basicApi.update(event.object.objectId, {"properties":{"firstname": searchResponse.body.results[0].first_name, "lastname": searchResponse.body.results[0].last_name}});
    });
          callback({outputFields: {}});
    
    })
    .catch(err => {
      console.error(err);
    });
}

 

0 Upvotes
1 Reply 1
jbogaert
HubSpot Moderator
HubSpot Moderator

Custom Code for Custom Object Search

Thanks for sharing this issue with us!

@FelipeFelix@davidoff2drew@MVandeHaar, is this something you might be able to help Kristeen with?