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.
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.
Hi DiePic,
You can follow below steps.
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.
Cheers,
Ketan
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.
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);
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156