Sometimes we want to change the HubSpot default settings of automatically assigning the “lead” lifecycle stage on creation to a different stage.
For example, I might want to create the “prospect” stage and only assign the lead stage once the contact has interacted in a specific manner with our company.
In systems with existing data this might be tricky, as applying it retroactively might cause issues in the tracking information that HubSpot stores.
To ensure a clean transitition, I want to write some code which adjusts the change accordingly. The proof of concept code in python looks something like this:
old_lcs = "521936119"
new_lcs = "556854491"
lc_properties = [
"lifecyclestage",
f"hs_v2_date_entered_{old_lcs}",
f"hs_v2_date_entered_{new_lcs}",
f"hs_v2_date_exited_{old_lcs}",
f"hs_v2_date_exited_{new_lcs}",
f"hs_time_in_{old_lcs}",
f"hs_time_in_{new_lcs}",
]
contacts = list(get_object(client.crm.contacts, properties=lc_properties))
first_contact = contacts[0]
pprint(first_contact)
# update lifecycle to new and replace values
update_model = SingleUpdateModel(
id=first_contact.id,
id_name="contact_id",
properties={
"lifecyclestage": new_lcs,
f"hs_v2_date_entered_{old_lcs}": None,
f"hs_v2_date_exited_{old_lcs}": None,
f"hs_time_in_{old_lcs}": None,
f"hs_v2_date_entered_{new_lcs}": first_contact.properties[
f"hs_v2_date_entered_{old_lcs}"
],
f"hs_v2_date_exited_{new_lcs}": first_contact.properties[
f"hs_v2_date_exited_{old_lcs}"
],
f"hs_time_in_{new_lcs}": first_contact.properties[f"hs_time_in_{old_lcs}"],
},
)
updated_record = update(client.crm.contacts, update_model)
pprint(updated_record)
However, this is not possible since the tracking properties are “read only”. This is unfortunate, as it makes changing the lifecyclestage setup a risky endeavour.
Does anyone have experience with these types of changes who can advice on the best course of action?