Workflow Custom Code Write to Contact Property

Hi all,

Is it possible to write to a Contact property when using the Custom Code in Worflows? I’m using Python. If so, could someone please point me to the documentation?

I’m thinking it should look something like this, but with “update” instead of “get_by_id”:

hubspot.crm.contacts.basic_api.get_by_id(hs_contact_id, properties=[“phone”])

Thanks for the help!

Hi, @isabeli. Thanks for your question. An easy way to test this is to use the on-page PATCH example here (endpoints tab) and use the Python example. This should give you something to take and modify for use in your custom coded workflow action. Additionally, if you have already tried to send a similar request, can you share it along with the error being returned, please?

Thank you! — Jaycee

Thank you for pointing me to that endpoint! That helped a lot. Here’s what ended up working for me:

 hubspot.crm.contacts.basic_api.update(
 hs_contact_id, 
 {
 "properties": {
 "gclid": "test_gclid",
 }
 }
 )
  • hs_contact_id = Record ID
  • gclid is the name of the property I updated
  • test_gclid is the valid that I set gclid to

Fantastic! Thank you very much for sharing what worked. Have fun coding! — Jaycee

but if we are using multiple Property IDs, how do we define which is the correct record ID?

I am trying to do the same thing here, but it’s not working for me. Is this the whole code?