如何在类方法中返回数组或容器

时间:2016-03-22 09:31:29

标签: axapta dynamics-ax-2012

我在方法currentUserId()中编辑了类:AxaptaUserManager。

我编辑的代码:

public static str currentUserId()
{
    str userSingle;
    ;

    userSingle = 'azn03';

    return userSingle;
}

我在我的查询中将上面的方法放在范围内:

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

然后,我创建连接查询和角色的策略:

Policy

最后,我将一个用户添加到' TradeSalesRepresentative'。

结果与预期不符,表格SalesTable显示所有销售员的所有销售订单。我的目的是以SalesTable形式过滤销售订单。我的步骤有什么不对吗?

1 个答案:

答案 0 :(得分:2)

使用此方法;

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

...进入班级SysQueryRangeUtil

要返回/过滤范围,请像手动设置过滤器一样格式化字符串,逗号分隔。