-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#736 Retrieve a lookup field value example, type hints for List colle…
…ction
- Loading branch information
Showing
6 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Demonstrates how to retrieve a lookup field values from SharePoint List | ||
""" | ||
from office365.sharepoint.client_context import ClientContext | ||
from tests import test_client_credentials, test_team_site_url | ||
|
||
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials) | ||
|
||
list_tasks = ctx.web.lists.get_by_title("Company Tasks") | ||
items = ( | ||
list_tasks.items.get() | ||
.select( | ||
[ | ||
"*", | ||
"AssignedTo/Id", | ||
"AssignedTo/Title", | ||
"Predecessors/Id", | ||
"Predecessors/Title", | ||
] | ||
) | ||
.expand(["AssignedTo", "Predecessors"]) | ||
.top(10) | ||
.execute_query() | ||
) | ||
for item in items: | ||
assigned_to = item.properties.get("AssignedTo", {}).get("Id", None) | ||
predecessors_ids = [ | ||
v.get("Id", None) for k, v in item.properties.get("Predecessors", {}).items() | ||
] | ||
print( | ||
"AssignedTo Id: {0}, Predecessors Ids: {1}".format( | ||
assigned_to, predecessors_ids | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters