Skip to main content

Notifications

Microsoft Dynamics CRM forum
Suggested answer

To retrieve a list of teams with whom an opportunity is shared in Dynamics 365 CRM

editSubscribe (0) ShareShare
ReportReport
Posted on by 2
Hi,
I have an requirement to  retrieve a list of teams with whom an opportunity is shared in Dynamics 365 CRM. I can retrive users  but not teams.Is there any wat to do?

Thanks in advance
  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,937 Super User on at
    To retrieve a list of teams with whom an opportunity is shared in Dynamics 365 CRM
  • Suggested answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    To retrieve a list of teams with whom an opportunity is shared in Dynamics 365 CRM
    Hi,

    Information relating to the Sharing of records in Dataverse/Dynamics 365 is held in the PrincipalObjectAccess(POA) table. 

    https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/reference/principalobjectaccess?view=dataverse-latest 

    principaltypecode:stores the entity name of the user or team with which the record is shared.

    principalid:store the GUID of the team or user.

    For example:

    Code:

    Xrm.WebApi.retrieveMultipleRecords("principalobjectaccess", "?$select=objectid,objecttypecode,principalid,principaltypecode&$filter=(objectid eq fdf62c03-cf7e-4cc4-a065-b1464913de27 and principaltypecode eq 'team')").then(
    	function success(results) {
    		console.log(results);
    		for (var i = 0; i < results.entities.length; i++) {
    			var result = results.entities[i];
    			// Columns
    			var principalobjectaccessid = result["principalobjectaccessid"]; // Guid
    			var objectid = result["objectid"]; // Guid
    			var objecttypecode = result["objecttypecode"]; // EntityName
    			var objecttypecode_formatted = result["objecttypecode@OData.Community.Display.V1.FormattedValue"];
    			var principalid = result["principalid"]; // Guid
    			var principaltypecode = result["principaltypecode"]; // EntityName
    			var principaltypecode_formatted = result["principaltypecode@OData.Community.Display.V1.FormattedValue"];
    		}
    	},
    	function(error) {
    		console.log(error.message);
    	}
    );
    Using Dataverse REST Builder tool to build it easily:
    1)Build request
    2)Execute code:
    3)Result:
    --Get guid of the team

    I hope you can mark my answer verified if it answer your question! If you have any questions, please feel free to contact me.
    Regards,
    Leah
     

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,375 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans