Announcements
Hi Friends,
I am trying to give the CurrentUserId() method from SysQueryRangeUtil class as the range in the static query (AOT query) to filter the record related to the currnent user.
The value is not getting filtered. if I hard-code the current user id as "abcuser" in the range it works fine
Note: we cannot use the metnod "curUserId()". we need to use method from the class SysQueryRangeUtil.
Have you come across this kind of issue?
your help much appreciated.
Regards
Martin
Hi Martin,
As you mentioned, my query was combined with tables and views, unfortunately my range was in the view and so it took only one userID during the synchronization.
Regards
Martin
This can't work. The method will be executed just once, on synchronization, and this single user ID will be included in the view definition.
If you need a view, let it return a column with user IDs and filter this column in a query.
Hi Martin,
But it's not a query object. I'm not sure if it's working for views as views are physically created in DB as real SQL views.
Hi Sergi,
Basically I wanted to create a static query to be applied in the security policy for XDS purpose and wanted to filter the data based on the current user who logged-in. when I attached that query in a View and opened in the table browser, it did not filter the record. if I give one user value as a string (e.g: "abcUser") then it works fine, but if I give as (CurrentUserId()) it is not filtering the record.
For testing purpose i created a simple view and added "purchTable" as datasource and and added "createdBy" field as range and gave the range value as "(currentUserid()), it did not filter the data for me.
Hi Martin,
How do you run operation (batch or not)?
Hi Sergei,
I am using dynamics 365 F&O (Update31), I had put the range as Martin suggested only but, it does not filter the record based on the current user ID.
Regards
Martin. A
HI Martin Arul,
The SysQueryRangeUtil class includes a number of functions that list pages used to dynamically control the data that is shown based on the value that id returned by the function.
As mentioned, The function call has to use the same syntax as passing expressions in a range value.the whole value needs to be surrounded by an opening "(" and closing ")".
Please refer : community.dynamics.com/.../using-dynamic-query-values-sysqueryrangeutil-in-dynamics-ax-115157664
Put class method directly in datasource range node as (SysQueryRangeUtil::currentUserId()).
Hi Martin,
Martin Dráb is right, (currentUserId()) is the correct statement. I can confirm that it works. How did you decide that it doesn't work? Maybe you expect another behavior?
Hi Martin,
I gave the range value as you suggested only. I gave within the brackets but it did not work as well.
I tried the following ways:
(CurrentUserId())
SysQueryRangeUtil::CurrentUserId()
(SysqueryRangeUtil::CurrnetUserId())
none of it seem to work.
Regards
Martin
How did you try to use it? Do you know that the value must be (currentUserId()) and not just currentUserId()?
André Arnaud de Cal...
293,323
Super User 2025 Season 1
Martin Dráb
232,195
Most Valuable Professional
nmaenpaa
101,158
Moderator