Select to view content in your preferred language

Write to Variables from Query

404
1
Jump to solution
03-23-2023 12:28 PM
kapalczynski
Frequent Contributor

I am doing a query of my Portal Items like below and get the result like below.

I want to take this a bit further and test the "Item Title" and only process a few of the returned items

 

search_result = source.content.search(query="owner:"+str(source_owner), item_type="Web Map")

for item in search_result:
    app=source.content.get(item.id)
    data = [app]
    print(data)

 

Result

[<Item title:"AAH Demo Public" type:Web Map owner:someone>]
[<Item title:"AAH Demo" type:Web Map owner:someone>]
[<Item title:"AAH Demo Live Test" type:Web Map owner:someone>]
[<Item title:"AAH Demo" type:Web Map owner:someone>]

 

How would I get Item title to a variable?

print(data.title)

or something like that..... Not sure how to read that returned format into anything????

 

thoughts

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor
for item in search_result:
    print(item.title)

jcarlson_0-1679600077862.png

The list search_result already has the title as a property of each Item in it. You can reference the title directly in your loop.

- Josh Carlson
Kendall County GIS

View solution in original post

1 Reply
jcarlson
MVP Esteemed Contributor
for item in search_result:
    print(item.title)

jcarlson_0-1679600077862.png

The list search_result already has the title as a property of each Item in it. You can reference the title directly in your loop.

- Josh Carlson
Kendall County GIS