Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use managed termset #353

Closed
remotain opened this issue May 17, 2021 · 1 comment
Closed

How to use managed termset #353

remotain opened this issue May 17, 2021 · 1 comment
Labels

Comments

@remotain
Copy link

Hello,

Is there any example on how to use managed term set?

In particular, given a string of text, how to add the corresponding term to a list column?

@vgrem
Copy link
Owner

vgrem commented May 22, 2021

Greetings!

In the latest release it is supported to set taxonomy columns, here are a few examples:

Example: save a single-valued taxonomy field value

ctx = ClientContext(site_url).with_credentials(credentials)

tasks_list = ctx.web.lists.get_by_title("Tasks")
tax_field_value = TaxonomyFieldValue("{term-label}", "{term-guid}")
item_to_create = tasks_list.add_item({
    "Title": "New task",
    "{taxonomy-column-name}": tax_field_value,
}).execute_query()

Example: save a multi-valued taxonomy field value

ctx = ClientContext(site_url).with_credentials(credentials)

tasks_list = ctx.web.lists.get_by_title("Tasks")
tax_field_value = TaxonomyFieldValue("{term-label}", "{term-guid}")
tax_field_values = TaxonomyFieldValueCollection([tax_field_value])
item_to_create = tasks_list.add_item({
    "Title": "New task",
    "{taxonomy-column-name}": tax_field_values,
}).execute_query()

@vgrem vgrem closed this as completed May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants