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

An open collection property 'FieldName' was found. In OData, open collection properties are not supported. #134

Closed
Karthickraju2690 opened this issue Oct 21, 2019 · 3 comments

Comments

@Karthickraju2690
Copy link

Karthickraju2690 commented Oct 21, 2019

I am trying to create a list on SharePoint online. One of the fields is Multi-choice field.

If I run below code without passing value for Multi-choice, it's working fine now. But, does not work when run along with multi choice.

        app_settings = {
            'url': 'url',
            'client_id': 'clientid',
            'client_secret': 'secret'
        }

        context_auth = AuthenticationContext(url=app_settings['url'])
        context_auth.acquire_token_for_app(client_id=app_settings['client_id'], client_secret=app_settings['client_secret'])
        ctx = ClientContext(app_settings['url'], context_auth)
        item_properties = {'__metadata': {'type': 'SP.List'}, 'Title': 'Task Created by Python Script',
                           'FieldName':{
                               '__metadata' : {'type' : 'Collection(Edm.String)' },
                               'results': ['value1', 'value2']
                               }
                           }            
        item = list_object.add_item(item_properties)
        ctx.execute_query()

On running above query, receiving "An open collection property 'FieldName' was found. In OData, open collection properties are not supported." error

@ghost
Copy link

ghost commented Jun 13, 2021

Hi @Karthickraju2690,
I'm also facing same issue. I have gone through the git issue you mentioned above, but after trying all the possible solutions mentioned still I'm not able to resolve the error. Could you please help me out if you were able to solve yours?

Link to the issue I raised - #365

@vgrem
Copy link
Owner

vgrem commented Nov 8, 2021

Setting multi-choice field values is nowadays supported, here is an example:

target_list = client.web.lists.get_by_title(list_title)
item_to_update = target_list.get_item_by_id(item_id)
multi_choice_value = FieldMultiChoiceValue(["North Europe", "South Europe"])
item_to_update.set_property("Region", multi_choice_value).update().execute_query() 

@vgrem vgrem closed this as completed Nov 8, 2021
@sithankanna
Copy link

sithankanna commented Sep 13, 2022

Another pattern to create a new list item with a multi-choice value from the example above:

from office365.sharepoint.fields.multi_choice_value import FieldMultiChoiceValue 

target_list = client.web.lists.get_by_title(list_title)
multi_choice_value = FieldMultiChoiceValue(["North Europe", "South Europe"])

target_list.add_item({
    "Title": "Location A",
    "Region": multi_choice_value,
}).execute_query()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants