web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

List the users the opportunity is shared with

(0) ShareShare
ReportReport
Posted on by 448

Hi all

I need to have the list of users with whom the opportunity is shared (table PrincipalObjectAccess).

I think to make this with power automate, but I've not idea how to ... 

Thanks in advance for any help or Idea.

I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi DIE PIC,

    I do not think you can do it with Power Automate as the List rows action of dataverse is not showing the PrincipalObjectAccess.

    pastedimage1677055958083v1.png

    I have done it with the help of JS. Here is the code:

    // A namespace defined for the sample code
    // As a best practice, you should always define
    // a unique namespace for your libraries
    var Test = window.Test || {};
    (function () {
    // Define some global variables
    let entitysPluralName = {
    PrincipalObjectAccesss: "principalobjectaccessset"
    };
    let globalVariables = {
    Results: "",
    WebAPIVersion: "v9.1"
    };

    this.retrievePrincipalObjectAccess = function () {
    try {
    var fetchData = {
    opportunityid: this.getId()
    };
    var fetchXmlQuery = [
    "<fetch>",
    " <entity name='principalobjectaccess'>",
    " <attribute name='principaltypecode' />",
    " <attribute name='principalobjectaccessid' />",
    " <attribute name='principalid' />",
    " <link-entity name='opportunity' from='ecs_expenseid' to='objectid'>",
    " <filter type='and'>",
    " <condition attribute='opportunityid' operator='eq' value='", fetchData.opportunityid, "'/>",
    " </filter>",
    " </link-entity>",
    " </entity>",
    "</fetch>",
    ].join("");
    this.retrieve(globalVariables.WebAPIVersion, entitysPluralName.PrincipalObjectAccesss, fetchXmlQuery);
    if (globalVariables.Results.length > 0) {
    //your logic
    }
    }
    catch (e) {
    this.openAlertDialog("Error from getId: " + "e: " + e + ". e.mesage: " + e.message);
    }
    }

    this.retrieve = function (webAPIVersion, entitysPluralName, fetchXmlQuery) {
    try {
    var req = new XMLHttpRequest();
    req.open(
    "GET",
    parent.Xrm.Page.context.getClientUrl() +
    "/api/data/" + webAPIVersion + "/" + entitysPluralName + "?fetchXml=" +
    encodeURIComponent(fetchXmlQuery),
    false
    );//Sync
    req.setRequestHeader("Prefer", 'odata.include-annotations="*"');
    req.onreadystatechange = function () {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200) {
    var results = JSON.parse(this.response);
    globalVariables.Results = results.value;
    } else {
    alert(this.statusText);
    }
    }
    };
    req.send();
    } catch (e) {
    this.openAlertDialog("Error from retrieve: " + "e: " + e + ". e.mesage: " + e.message);
    }
    }

    this.getId = function (formContext) {
    let iD = "";
    try {
    iD = formContext.data.entity.getId();
    } catch (e) {
    this.openAlertDialog("Error from getId: " + "e: " + e + ". e.mesage: " + e.message);
    }
    return iD;
    }

    this.openAlertDialog = function (alertStrings) {
    try {
    Xrm.Navigation.openAlertDialog(alertStrings).then();
    } catch (e) {
    Xrm.Navigation.openAlertDialog("Error from openAlertDialog: " + "e: " + e + ". e.mesage: " + e.message).then();
    }
    }
    }).call(Test);

  • Verified answer
    NODAL Profile Picture
    860 on at

    Hi DiePic,

    You can follow below steps.

    1. In the list rows action, set table name as custom value,

    pastedimage1677060880556v1.png

    2. Type table name as principalobjectaccessset

    3.Fetch Query paste following query and replace opportunity id with you opportunity id as static or dynamic value.

    <fetch distinct="true">
    <entity name="principalobjectaccess">
    <attribute name="principalobjectaccessid" />
    <filter>
    <condition attribute="principaltypecode" operator="eq" value="8" />
    <condition attribute="objectid" operator="eq" value="9d3d18ff-5104-4173-9ed5-b1805793eea4" />
    </filter>
    <link-entity name="opportunity" from="opportunityid" to="objectid" link-type="inner" alias="opportunity">
    <attribute name="name" />
    </link-entity>
    <link-entity name="systemuser" from="systemuserid" to="principalid" link-type="inner" alias="user">
    <attribute name="fullname" />
    </link-entity>
    </entity>
    </fetch>

    4. Final action will look like this.

    pastedimage1677061065122v2.png

    Cheers,

    Ketan

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 184 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 125

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans