HubSpot: Difference between revisions

From Starfish ETL
Jump to navigation Jump to search
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:
While the HubSpot API documentation states that you should pass Dates to the HubSpot API in Unix format, https://legacydocs.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis, the Starfish HubSpot connector will do this conversion for you.  You do need to be sure to pass that date in a specific format and at midnight.  See the following examples.
While the HubSpot API documentation states that you should pass Dates to the HubSpot API in Unix format, https://legacydocs.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis, the Starfish HubSpot connector will do this conversion for you.  You do need to be sure to pass that date in a specific format and at midnight.  See the following examples.


Using API v3, for a date only field, you need to explicitly set the date to midnight UTC
Using API v3, for a date only field, you need to explicitly set the date to midnight UTC.  VBScript:
<syntaxhighlight lang="vb">
<syntaxhighlight lang="VBScript">
Function ScriptedField
Function ScriptedField
   ScriptedField=FormatDate("@@ORG:date_entered@@", "yyyy-MM-ddT00:00:00Z")
   ScriptedField=FormatDate("@@ORG:date_entered@@", "yyyy-MM-ddT00:00:00Z")
Line 9: Line 9:
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="csharp">
C#:
<syntaxhighlight lang="C#">
object ScriptedField()
object ScriptedField()
{
{
Line 23: Line 24:
}
}
</syntaxhighlight>
</syntaxhighlight>
See [[https://wiki.starfishetl.com/index.php/Using_Starfish_Scripting_Class_Properties_%26_Methods_in_C#Useful_Functions Using Starfish Scripting Class Properties & Methods in C#]] for ConvertObj2String.


=Updating Contacts=
=Updating Contacts=
When updating contacts, if you are matching on email address, you must be sure NOT to pass in a blank email address.  HubSpot will not know which contact to update and will update a random contact with incorrect data.  You can either exclude blank emails from your origin or check the "Skip if Blank" checkbox on the email address field.  I prefer to do both.
When updating contacts, if you are matching on email address, you must be sure NOT to pass in a blank email address.  HubSpot will not know which contact to update and will update a random contact with incorrect data.  You can either exclude blank emails from your origin or check the "Skip if Blank" checkbox on the email address field.  I prefer to do both.
=Updating Multiple Records With One Update=
Please be careful of updating multiple records with a single update call to the HS API.  The HubSpot API allows you to update multiple records with a single call.  In these cases, the HubSpot API will not return an ID for the record that was updated.  For example, if you are storing a foreign ID value in a custom "ForeignID" field and that field contains the same ID, ABC123, for 2 records, and you update the ID "ABC123", both records will be updated and HubSpot will not return an ID for the record that was updated.

Latest revision as of 19:52, 6 February 2023

Date Fields

While the HubSpot API documentation states that you should pass Dates to the HubSpot API in Unix format, https://legacydocs.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis, the Starfish HubSpot connector will do this conversion for you. You do need to be sure to pass that date in a specific format and at midnight. See the following examples.

Using API v3, for a date only field, you need to explicitly set the date to midnight UTC. VBScript:

Function ScriptedField
  ScriptedField=FormatDate("@@ORG:date_entered@@", "yyyy-MM-ddT00:00:00Z")
End Function

C#:

object ScriptedField()
{
    string strDte = ConvertObj2String(Starfish.OriginData["INVOICE_SENT_DATE_C"]);
    
    if (!string.IsNullOrEmpty(strDte))
    {
        DateTime dte = Convert.ToDateTime(strDte);
        strDte = dte.ToString("yyyy-MM-dd 00:00:00Z");
    }
    
	return strDte;
}

See [Using Starfish Scripting Class Properties & Methods in C#] for ConvertObj2String.

Updating Contacts

When updating contacts, if you are matching on email address, you must be sure NOT to pass in a blank email address. HubSpot will not know which contact to update and will update a random contact with incorrect data. You can either exclude blank emails from your origin or check the "Skip if Blank" checkbox on the email address field. I prefer to do both.

Updating Multiple Records With One Update

Please be careful of updating multiple records with a single update call to the HS API. The HubSpot API allows you to update multiple records with a single call. In these cases, the HubSpot API will not return an ID for the record that was updated. For example, if you are storing a foreign ID value in a custom "ForeignID" field and that field contains the same ID, ABC123, for 2 records, and you update the ID "ABC123", both records will be updated and HubSpot will not return an ID for the record that was updated.