Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
Getting values/data from list with an applied view
Hello
So I'm having trouble getting/validating data from my SharePoint list.
I know my view object doesn't contain any items, wherefore I have used xml to apply my view before extracting my list, but I still get columns that looks meta-ish and when comparing to my SP-list I'm missing new columns eg. "Last name".
I've used these resources as inspiration:
- https://github.com/vgrem/Office365-REST-Python-Client/issues/518
- https://github.com/vgrem/Office365-REST-Python-Client/issues/65
- https://social.msdn.microsoft.com/Forums/office/en-US/450651f6-4443-4222-a42f-66deea762216/caml-query-returning-all-items-despite-specified-view?forum=sharepointdevelopment
This is my current code:
ctx = get_ctx()
list_object = ctx.web.lists.get_by_title(LIST_TITLE)
ctx.load(list_object);
ctx.execute_query();
view = list_object.views.get_by_title(VIEW_TITLE)
ctx.load(view)
ctx.execute_query()
qry = CamlQuery()
qry.ViewXml ="<View><Where>{0}</Where></View>".format(view.properties["ViewQuery"])
list_items = list_object.get_items(qry)
ctx.load(list_items)
ctx.execute_query()
for item in list_items: # type: ListItem
print(*item.properties.items(), sep='\n') #Fields still looks meta-ish
break
So my question is how do I access the right/current columns from my SP-list through a view, and get the value of 'Last name' from my item?