QML - How to query portal group info for a user

3119
2
Jump to solution
06-28-2015 07:22 PM
by Anonymous User
Not applicable

Hi.

Can anyone point me in the right direction for any samples or code that shows how to query what groups a user belongs to on a portal. I can sign in to the portal ok. I can see several code samples on querying portal items such as web maps, but haven't come across any yet that show querying groups.

So far I have a Portal object, a PortalSearchParameters object, a PortalSearchGroups object and a button to fire the 'searchGroups' method of the PortalSearchGroups object, but I can't get the onRequestComplete signal to fire and can't access any results of the query, so I assume the query is failing somewhere.

Any ideas?

   PortalSearchParameters{   id: portalSearchParameters;     query: '*'; }

  PortalSearchGroups{ id: portalSearchGroups;  portal: myPortal;

onRequestStatusChanged: {

  if (requestStatus === Enums.PortalRequestStatusCompleted)   {

  console.log("request status is completed!")  }  }

  onRequestComplete: {   console.log("request is complete..............") }

  }

    Button{  id: testPortalSearchGroups; x: 300;    y: 300;   text: "Search Portal Groups";
   onClicked: {   console.log("test Portal groups button clicked")
   portalSearchGroups.searchGroups(portalSearchParameters);
  } 
  }


					
				
			
			
				
			
			
				
0 Kudos
1 Solution

Accepted Solutions
ThomasDunn
Occasional Contributor

Paul,

In 10.2.6 we did not expose in our API the REST portal user attribute for groups that the user belongs to. But don't despair, you can still get this information from the JSON of the portal user object.

onSignInCompleted: {
console.log("User", portal.user.fullName, "belongs to these groups:");
var groups = portal.user.json["groups"];
    if (groups) {
        for ( var i = 0; i < groups.length; i++) {
            console.log(groups["title"])
        }
    }
}

					
				
			
			
				
			
			
				
			
			
				

View solution in original post

0 Kudos
2 Replies
ThomasDunn
Occasional Contributor

Paul,

In 10.2.6 we did not expose in our API the REST portal user attribute for groups that the user belongs to. But don't despair, you can still get this information from the JSON of the portal user object.

onSignInCompleted: {
console.log("User", portal.user.fullName, "belongs to these groups:");
var groups = portal.user.json["groups"];
    if (groups) {
        for ( var i = 0; i < groups.length; i++) {
            console.log(groups["title"])
        }
    }
}

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
by Anonymous User
Not applicable

Great! Thanks for that Thomas.

Regards,

-Paul

0 Kudos