Select to view content in your preferred language

Fetch the group content items.

511
2
Jump to solution
07-03-2023 07:18 PM
DeepamPalaniswami
Occasional Contributor

Hi Team,

I have tried the below code to fetch the group info. Which was successful. But I couldn't able to fetch the contents of the Group.

val portalQueryParameters =
PortalQueryParameters(query = getString(R.string.group_id), limit = 20 )
val groups = portal.findGroups(portalQueryParameters)

I can fetch the group info such as Title which is all good. but I tried to below codes to fetch the item of a particular group based on Id.

val groupId = groups.getOrNull()?.results?.get(0)?.id
val portalGroupContentSearchParameters = PortalGroupContentSearchParameters.query(query = groupId ?: "")
val items = groups.getOrNull()?.results?.get(0)?.findItems(portalGroupContentSearchParameters)

Is that something I am missing. result is success but the item count is 0. But I can view the content items from a ArcGIS web login. I can see 2 items.

I also tried the below code snippet. Items are 0.

val portalQueryParameters =
PortalQueryParameters(query = getString(R.string.group_id), limit = 20 )
val items = portal.findItems(portalQueryParameters)

Is that something related to user access to group items? 


Need your help in understanding the flow.

 

Thanks

 

0 Kudos
1 Solution

Accepted Solutions
DeepamPalaniswami
Occasional Contributor

Hi ArcGIS,

I am able to fetch all the items in the group passing empty string in PortalGroupContentSearchParameters.

Thanks for your support. refer below code snippet if anyone needs to know.

val portalGroupContentSearchParameters = PortalGroupContentSearchParameters.query("")
val items = groupinfo?.results?.get(0)?.findItems(portalGroupContentSearchParameters)

 

View solution in original post

0 Kudos
2 Replies
DeepamPalaniswami
Occasional Contributor

Hi ArcGIS,

I am able to fetch all the items in the group passing empty string in PortalGroupContentSearchParameters.

Thanks for your support. refer below code snippet if anyone needs to know.

val portalGroupContentSearchParameters = PortalGroupContentSearchParameters.query("")
val items = groupinfo?.results?.get(0)?.findItems(portalGroupContentSearchParameters)

 

0 Kudos
SorenRoth
Esri Contributor

Hello, 

I am glad you found a workaround. To query specifically for your group items, you can use 

 

val groupId: String = ...
val
portalGroupContentSearchParameters = PortalGroupContentSearchParameters.query("id:$groupId")

 

There is documentation on the query syntax here 

0 Kudos