# Custom Code for Custom Object Search

**URL:** <https://community.hubspot.com/t/custom-code-for-custom-object-search/45873>\
**Category:** Data Hub\
**Created:** [October 25, 2021, 11:08am UTC](https://community.hubspot.com/t/custom-code-for-custom-object-search/45873 "2021-10-25T11:08:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KristeenRomero](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kristeenromero/32/51926_2.png) [@KristeenRomero](https://community.hubspot.com/u/KristeenRomero)\
**Post date:** [October 25, 2021, 11:08am UTC](https://community.hubspot.com/t/custom-code-for-custom-object-search/45873/1 "2021-10-25T11:08:24Z")

</div>

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)

```lia-code-sample
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);
 });
}

```

---

<div class="post-metadata">

**Author:** ![jbogaert](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbogaert/32/33027_2.png) [@jbogaert](https://community.hubspot.com/u/jbogaert)\
**Post date:** [October 26, 2021, 9:34am UTC](https://community.hubspot.com/t/custom-code-for-custom-object-search/45873/2 "2021-10-26T09:34:14Z")

</div>

Thanks for sharing this issue with us!  
@FelipeFelix, @davidoff2drew, @MVandeHaar, is this something you might be able to help Kristeen with?
