Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

RetrieveMultiple Not Trigger on Report view

(0) ShareShare
ReportReport
Posted on by 30

Hi

I have a requirement to limit access to View of Report on security role. So I'm working on a plugin on retrievemultiple message. Basically the plugin check user's security role then the view should not be visible.  I registered the plugin on retrievemultiple message on savedquery. 

This is the code.

FetchExpression fe = context.InputParameters["Query"] as FetchExpression;
var fetchToQueryExpressionRequest = new FetchXmlToQueryExpressionRequest
{
FetchXml = fe.Query
};
var fetchToQueryExpressionResponse = (FetchXmlToQueryExpressionResponse)service.Execute(fetchToQueryExpressionRequest);
QueryExpression objQueryExp = fetchToQueryExpressionResponse.Query;

if (objQueryExp.EntityName == "savedquery")
{
trace.Trace("qe.EntityName:");
trace.Trace(objQueryExp.EntityName.ToString());
if (objQueryExp.Criteria != null)
{
trace.Trace("qe.Criteria:");
trace.Trace(objQueryExp.Criteria.ToString());
if (objQueryExp.Criteria.Conditions != null)
{
trace.Trace("qe.Criteria.Conditions:");
trace.Trace(objQueryExp.Criteria.Conditions.ToString());
string roleName = "System Administrator";
bool userRoleFound = VerifyIfUserHasRole(roleName, context.UserId, service);
if (userRoleFound)
{
trace.Trace("userRoleFound:");
trace.Trace(userRoleFound.ToString());
ConditionExpression queryCondition = new ConditionExpression("name", ConditionOperator.Equal, "Admin Reports");
trace.Trace("userRoleFound:");
trace.Trace(queryCondition.ToString());
objQueryExp.Criteria.Conditions.Add(queryCondition);
}
}
}
}

It is not getting triggered on the View

This is the Plugin Registeration.

pastedimage1594215586070v1.png

Thanks

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: RetrieveMultiple Not Trigger on Report view

    I'm afraid that you can't implement this requirement with a plugin.

  • Tjalui Profile Picture
    Tjalui 30 on at
    RE: RetrieveMultiple Not Trigger on Report view

    savedquery is the View Entity and I am using that because I am not able to use Report Entity as primary entity while registering the plugin.

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: RetrieveMultiple Not Trigger on Report view

    Sorry ! So you should use your Report Entity as primary entity not savedquery entity.

  • Tjalui Profile Picture
    Tjalui 30 on at
    RE: RetrieveMultiple Not Trigger on Report view

    I want to limit access of the specific view of Report Entity and not the Report.

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: RetrieveMultiple Not Trigger on Report view

    Hi, 

    You can't execute a plugin when a report is run.

    There is a hack, please check Nick response on stackoverflow: https://stackoverflow.com/questions/33904292/ms-crm-plugin-at-report-execution

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans