❕ NOTE: The Hubspot API is set up so that if a field is empty, it won't be returned in any way, shape, or form in the returned results. That is to say, not even the name field would be returned if a contact object contained a name field with a null value. Therefore, even if there is a little risk that the return will be null or the call will fail, Fallback values should be utilized for each return value.
When empty fields are detected, the HubSpot API will throw an error and not return any results. If you want to update another service or database that is waiting for a result, this presents an issue because it will halt the workflow.
Debugging might be challenging when both the field and the value are absent from the Input and Output panels.
Therefore, whenever a HubSpot value is anticipated to be returned, Fallback values should be utilized. Once more, even if the value is only an empty string, it will be sufficient to address this problem.
The code example below shows a contact object arriving from an arbitrary webhook service. It includes a null value in the phone field among other things:
"name": "Andre Webber",
When this is asked of your HubSpot workflow, it will fail and terminate since the value that is attempting to be changed is null:
"message": "Reference: $.steps.hubspot-1.response.body.employees.phone.value in property: 'data.value' did not resolve to any value."
"message": "There was an error creating connector input. See the input panel for details."
For such circumstances, fallback values produce a secure buffer. Your process will be able to run even if there is no "actual" data for that field since they offer a "response" that the HubSpot API can handle.
For more comprehensive details on the subject, you might also want to look over our documentation on Fallback values.
Within HubSpot, there are two ways to specify fallback values. Please be aware that we strongly advise using the Manual technique instead of the code-based option.
- Manual method: This is suggested for almost all use cases.
- Even the least technically inclined user may design with error handling in mind thanks to the Fallback values functionality that has been set up in Tray.io. Because the set settings are so obvious, the manual method also makes handovers simpler. See the walkthrough below for further information.
🛈 TIP for USERS: To further demonstrate how v5.X of the connector can be used, this description deliberately includes steps that use the Raw HTTP Request. This is due to HubSpot v5.X's limited operations at the time this example was written and the fact that it was undergoing changes. Go straight to Step 6 if you want to see the Manual Fallback approach.
Since this solution makes use of the manual fallback options found in the Tray.io properties panel, it requires less technical expertise from both the designer and future users.
A list of employee contacts are compiled and iterated over in this procedure. It then gathers the associated record details and assigns the data to a Google sheet. If no value is available for the Hubspot field referenced, instead of erroring a Fallback value is supplemented.
Since the data must be validated, invoked, and handed across in this demonstration, the HubSpot Fallback values are set in the Google sheets connector. For further information, see Step 6.
Your final result should resemble what is seen below:
🛈 EXTRA AUTHS: You will also need to be authenticated with the Google sheets connector in order to finish this procedure.
❕ NOTE: Keep in mind that this example uses HubSpot connection version 5.1 and Raw HTTP Request operations. As a result, it uses the HubSpot API Documentation, version 1.0.
- You must have Google sheets authentication set up and use the HubSpot 'Raw HTTP Request' operation because the goal of this workflow is to copy employee contact information from HubSpot into a Google sheet.
- A brief glance at the documentation reveals that we must utilize the 'Get all contacts' endpoint in order to compile a list of all contacts accessible within the related HubSpot account:
- This will now compile a list of every contact that is currently stored in your Hubspot account. The specifics for each interaction are, however, limited, as the Output panel demonstrates.
They don't have a lot of the fundamental details we need to move across. This API call lacks the employee's job title, phone number, etc. As a result, we must make another call and repeat the process with each contact.
b. Following the installation of the Loop step, the 'Loop list operation' will search through each employee contact that was discovered. This time, the 'Get contact by ID' endpoint is used in a 'Raw HTTP Request' operation:
This gives back all the characteristics that are currently connected to this specific Contact ID record. For a cleaner outcome, try using interpolation within your "Endpoint" property.
Not all prospective properties will be returned; only those that are affiliated will. Here is where you may find more details.
- The HubSpot Fallback values are specified in the Google Sheets connector because here is where the values need to be validated, called, and sent.
Make sure to set the "Spreadsheet ID" and "Worksheet name" properties when using the "Create row" action. The latter is typically set to "Sheet 1" by default and can be chosen using the dropdown menu.
Setting Fallback Values
- If a field in your database has a null value, you can receive error messages that look something like what is shown below. In this instance, the employee field—that is, the individual's job title—is absent.
As you can see, the message that was returned is unclear regarding the nature of the issue. Fortunately, we already know that this is a result of the field having a null value.
- Checking the Debug panel is the first step in setting Fallback values. We may utilize the connector-snake to set the jsonpath after confirming what is being returned or coming in from our second HubSpot step ('Get contact details').
To enable the Fallback option after completing this, mouse over the 'Row data' -> 'Field' -> 'Value'. For further information on how Fallback values can be set, follow the numbered steps.
Now, when a null value is discovered in the "Job title" field, the Fallback value is sent instead of stopping the workflow and returning an error: