Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Query for policy

Posted on by 40

Hello,

need some help with one issue.

I have Query AOT that I using in Policy. Problem is that i have one dynamic range for one of tables. I should add current user id to range value.

I tried to solve it by setting rangeField in init method, but policy execute pure query (do not invoke init method). 

Is there a change to put method into range parameter or any other ways to solve this problem?

*This post is locked for comments

  • Verified answer
    Skribl Profile Picture
    Skribl 40 on at
    RE: Query for policy

    Sorry,

    SysQueryRangeUtil::currentUserId() worked. Thank you ;)

    i put class method directly in datasource range node as (SysQueryRangeUtil::currentUserId()).

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Query for policy

    a workable way that i have done in past was

    1) creating a table that has refresh frequency per session. You can find many table named as e.g. MyLegalEntities etc. similarly you can create a table named MyUserId. Keep refresh frequency per session.

    2) in your query make a join with MyUserId (Table)

    3) use your query in Security Policy

    if you will follow the white paper from Microsoft, that has example based on similar architecture  

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Query for policy

    It would be helpful if you tell us more, like do you have any error or what?

  • Skribl Profile Picture
    Skribl 40 on at
    RE: Query for policy

    Nope it do not work. I need to put some dynamic value in Datasource range node.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Query for policy

    Did you try SysQueryRangeUtil::currentUserId() ? You can read about SysQueryRangeUtil usage here blogs.msdn.microsoft.com/.../using-dynamic-query-values-sysqueryrangeutil-in-dynamics-ax

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans