# Identical Custom Code stopped working in a new workflow

**URL:** <https://community.hubspot.com/t/identical-custom-code-stopped-working-in-a-new-workflow/114173>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [August 9, 2024, 2:10pm UTC](https://community.hubspot.com/t/identical-custom-code-stopped-working-in-a-new-workflow/114173 "2024-08-09T14:10:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdierckx](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@mdierckx](https://community.hubspot.com/u/mdierckx)\
**Post date:** [August 9, 2024, 2:10pm UTC](https://community.hubspot.com/t/identical-custom-code-stopped-working-in-a-new-workflow/114173/1 "2024-08-09T14:10:10Z")

</div>

We have a workflow that includes a workflow and works flawlessly (query on companies).

The API called is (but this is not so relevant). The major issue where can I have an overview of the differrences between the different version for a specific call.

// Create search criteria  
const filter1 = { propertyName: ‘kunnr\_\_c’, operator: ‘EQ’, value: soldto }  
const filter2 = { propertyName: ‘sales\_organization\_\_c’, operator: ‘EQ’, value: soldtoorganisation }  
const filterGroup = { filters: [filter1,filter2] }  
const sort = JSON.stringify({ propertyName: ‘createddate\_sap\_\_c’, direction: ‘DESCENDING’ })  
const properties = [‘createddate\_sap\_\_c’]  
const limit = 1  
const after = 0

const searchCriteria = {  
filterGroups: [filterGroup],  
sorts: [sort],  
properties,  
limit,  
after  
}

hubspotClient.crm.companies.searchApi.doSearch(searchCriteria).then(searchCompanyResponse =\>

The custom code is written in node v16 on hubspot client v3 and indeed finds a company in line with the query

When I copy the same code in a new workflow also using hubspot client v3 with the same values no company is any longer found

```auto
CollectionResponseWithTotalSimplePublicObject {
 total: undefined,
 results: undefined,
 paging: undefined
} error

```

As the node version and client are the same I would imagine that it would also return a result.

---

<div class="post-metadata">

**Author:** ![JessieS](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@JessieS](https://community.hubspot.com/u/JessieS)\
**Post date:** [August 13, 2024, 12:28am UTC](https://community.hubspot.com/t/identical-custom-code-stopped-working-in-a-new-workflow/114173/2 "2024-08-13T00:28:38Z")

</div>

Hi @mdierckx!  
Good afternoon! From my understanding:

- You have a workflow that has a custom code that queries companies and seems to work fine.
- The custom code is written in node v16 and uses v3 API endpoints, successfully finding the company in line with the query
- However, when you copy the same code in a new workflow also using v3 API endpoints with the same values no company is found and you get an “undefined” error.

Based on this [similar error reported](https://community.hubspot.com/t5/APIs-Integrations/Workflow-custom-code-error/m-p/933977#M71476) it could be pointing to an undefined object.  
If you have access to workflows, you should have access to technical support on a Professional level account. Have you tried opening up a support ticket?  
While it would be out of scope to advise on custom code, support could take a look at the errors in the workflow if there are any or a response error with an API call you’re doing if you provide them with the following:

- Link to workflow
- Link to example record that had an issue
- API endpoint you’re using
- The API call body
- The API call header
- The response
- If you have a video reproducing the issue  
But I also wanted to extend this query to [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) @miljkovicmisa @Humashankar in case you’ve come across this before and have some ideas!  
Thank you,  
Jessie  
Community Moderator
