1
votes

I edited the class : AxaptaUserManager in method currentUserId().

My edited code :

public static str currentUserId()
{
    str userSingle;
    ;

    userSingle = 'azn03';

    return userSingle;
}

I put method above for range in my query :

Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: QUE

; Microsoft Dynamics AX Query: ABU_HCMWorker03 unloaded
; --------------------------------------------------------------------------
VERSION 31

QUERY #ABU_HCMWorker03
PROPERTIES
   Name                #ABU_HCMWorker03
   Version             #29
   NextUniqueId        #1003
   Origin              #{DC53FD0D-7322-447E-8393-3FCA091A6CE1}
ENDPROPERTIES

METHODS
SOURCE #classDeclaration
  #public class QueryRun extends ObjectRun
  #{
  #}
ENDSOURCE
ENDMETHODS
BLOCKS
BLOCK #HcmWorker
  PROPERTIES
    Name                #HcmWorker_1
    Table               #HcmWorker
    UniqueId            #1000
    FetchMode           #1:1
  ENDPROPERTIES

  FIELDLIST
    PROPERTIES
      Dynamic             #Unselected
    ENDPROPERTIES

  ENDFIELDLIST
  SORTING
  ENDSORTING
  LINES
  ENDLINES
  BLOCKS
    BLOCK #DirPerson
      PROPERTIES
        Name                #DirPerson_1
        Table               #DirPerson
        UniqueId            #1001
        FetchMode           #1:1
        Relations           #Yes
      ENDPROPERTIES

      FIELDLIST
        PROPERTIES
        ENDPROPERTIES

      ENDFIELDLIST
      SORTING
      ENDSORTING
      LINES
      ENDLINES
      BLOCKS
        BLOCK #DirPersonUser
          PROPERTIES
            Name                #DirPersonUser_1
            Table               #DirPersonUser
            UniqueId            #1002
            FetchMode           #1:1
            Relations           #Yes
          ENDPROPERTIES

          FIELDLIST
            PROPERTIES
              Dynamic             #Unselected
            ENDPROPERTIES

          ENDFIELDLIST
          SORTING
          ENDSORTING
          LINES
            LINE #User
            PROPERTIES
              Name                #User
              Table               #DirPersonUser
              Field               #User
              Value               #(currentUserId())
            ENDPROPERTIES

          ENDLINES
          BLOCKS
          ENDBLOCKS
          ASSOCIATIONS
            ASSOCIATION
              FOREIGNKEYRELATION #DirPerson
          ENDASSOCIATIONS
        ENDBLOCK
      ENDBLOCKS
      ASSOCIATIONS
        ASSOCIATION
          FOREIGNKEYRELATION #DirPerson
      ENDASSOCIATIONS
    ENDBLOCK
  ENDBLOCKS
  GROUPBY
  ENDGROUPBY
  HAVING
  ENDHAVING
  ORDERBY
  ENDORDERBY
ENDBLOCK
ENDBLOCKS
DEPENDENTS
ENDDEPENDENTS
COMPOSITEQUERIES
ENDCOMPOSITEQUERIES
ENDQUERY


***Element: END

Then, i create policy which connect query and role :

Policy

Last, i add one user to 'TradeSalesRepresentative'.

The result is not as expected, in form SalesTable shows all sales order from all salesman. My purpose is filter sales order in SalesTable form. Is there anything wrong in my step ?

1
Perhaps you can avoid the code changes to do your testing and use the runas.exe command. The Security Development Tool is also a great way to test your security changes. - ian_scho
I dont know how to use Security Development Tools. Running from runas.exe command, also gave unexpected result. - Setiaji

1 Answers

2
votes

Put this method;

public static str currentUserId()
{
    return 'azn03';
}

...into the class SysQueryRangeUtil.

To return/filter a range, format the string as you would if you set the filter manually, comma-seperated.