# Changing hs\_language with within workflow

**URL:** <https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503>\
**Category:** CRM\
**Tags:** enterprise\
**Created:** [December 19, 2022, 1:59pm UTC](https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503 "2022-12-19T13:59:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartecDaniel](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MartecDaniel](https://community.hubspot.com/u/MartecDaniel)\
**Post date:** [December 19, 2022, 1:59pm UTC](https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503/1 "2022-12-19T13:59:55Z")

</div>

Hi folks!

I am struggling a bit with changing hs\_language within a workflow.

I have the information for the preferred language on the company properties in an single line field. The information is exactly in the format hs\_language is made of (de-de, de-at and so on).

But I need the information mirrored to the contact as well. I cannot copy to hs\_language - it does not show up the my dropdown of fields to copy to. I guess it is blocked because it is a hubspot (dropdown) field which cannot be loaded with any other values than the given.

Anyone has an idea how I can copy the information from the companies single line text to hs\_language?

The only thing I came up was in a biiiiiiiig workflow with a lot if “ifs” to map every line. thats a lot… and would cost me ages and a headache.

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [December 19, 2022, 4:38pm UTC](https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503/2 "2022-12-19T16:38:46Z")

</div>

Hey @MartecDaniel,

thank you for reaching out to the community. Sounds like an interesting case.

I’ve tried recreating it, and it’s the same for me as you are describing it. So it appears HubSpot is blocking that property from being copied to.

If/thens sounds like a lot of hassle indeed and wouldn’t feel smart. Do you by any chance have an Operations Hub Pro license? If so, I would be able to write a short piece of code for a custom code action that would be able to do the trick.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![MartecDaniel](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MartecDaniel](https://community.hubspot.com/u/MartecDaniel)\
**Post date:** [December 19, 2022, 5:48pm UTC](https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503/3 "2022-12-19T17:48:46Z")

</div>

Hey @ChrisoKlepke ,

yes we have the OperationsHub. The problem is, I can’t find the company property prefered\_language in the custom code section (I can of course create a custom property with the copied value from the company but would like to avoid that. )

 ![MartecDaniel_0-1671472120483.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/5/b/5bebcfae0db85578edd90f645a4d41281f691ae1.png)

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [December 19, 2022, 7:21pm UTC](https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503/4 "2022-12-19T19:21:33Z")

</div>

Hey @MartecDaniel,

no worries, I try my best to walk you through that. But just in case I like summerize to make sure I understood you correctly.

You have a company-based workflow that runs, probably on something _preferred\_language is known_.

And you like to copy the language code to all associated contacts of that company.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [December 19, 2022, 9:42pm UTC](https://community.hubspot.com/t/changing-hs-language-with-within-workflow/71503/5 "2022-12-19T21:42:00Z")

</div>

Hey again,

if my assumption from earlier were correct, this should be the code to get you going:

```lia-code-sample
import os
from pprint import pprint
from hubspot import HubSpot
from hubspot.crm.contacts import (
 ApiException as ContactApiException,
 SimplePublicObjectInput,
)
from hubspot.crm.companies import ApiException as CompanyApiException

def main(event):

 hubspot = HubSpot(access_token=os.getenv("hs_access_token"))

 company_lang = event.get("inputFields").get("preferred_language")
 company_id = event.get("object").get("objectId")

 try:
 get_assoc_contacts = hubspot.crm.companies.associations_api.get_all(
 company_id=company_id, to_object_type="CONTACT"
 )
 # pprint(get_assoc_contacts) # uncomment for debug

 except CompanyApiException as exception:
 pprint(exception)

 for contact in get_assoc_contacts.results:
 contact_id = contact.id

 update_properties = SimplePublicObjectInput(
 properties={"hs_language": company_lang}
 )

 try:
 update_contact_lang = hubspot.crm.contacts.basic_api.update(
 contact_id=contact_id, simple_public_object_input=update_properties
 )
 # pprint(update_contact_lang) # uncomment for debug
 except ContactApiException as exception:
 pprint(exception)

 return

```

Make sure to include the property which is storing the company language in the section _Properties to include in code_ as _preferred\_language._

Also make sure to include your access token as _hs\_access\_token_ and see if the Private App has the scopes for writing and reading companies and contacts.

Please let me know how it goes.

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I’d really appreciate it.

Cheers,

Chriso
